RosettaCodeData/Task/Nth/FutureBasic/nth.basic
2026-02-01 16:33:20 -08:00

21 lines
534 B
Text

CFStringRef local fn ordinalSuffix( num as int )
num = ( num % 100 / 10 - 1 ) ? num % 10 * 2 : 0
end fn = mid( @"thstndrdththththththth", num, 2 )
void local fn show( min as int, max as int )
int sz = len( str(max) ) + 2, count = 54 / sz
CFStringRef f = concat( @"%", mid( str( sz ), 1 ), @"d%@\b" )
for int i = min to max
printf f, i, fn OrdinalSuffix( i )
if !( ( i + 1 - min ) % count ) then print
next
print @"\n"
end fn
// DEMO //
fn show( 0, 25 )
fn show( 250, 265 )
fn show( 1000, 1025 )
handleevents