RosettaCodeData/Task/Nth/FutureBasic/nth.basic

22 lines
534 B
Text
Raw Permalink Normal View History

2026-02-01 16:33:20 -08:00
CFStringRef local fn ordinalSuffix( num as int )
num = ( num % 100 / 10 - 1 ) ? num % 10 * 2 : 0
end fn = mid( @"thstndrdththththththth", num, 2 )
2024-11-04 20:28:54 -08:00
2026-02-01 16:33:20 -08:00
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
2024-11-04 20:28:54 -08:00
next
2026-02-01 16:33:20 -08:00
print @"\n"
2024-11-04 20:28:54 -08:00
end fn
2026-02-01 16:33:20 -08:00
// DEMO //
fn show( 0, 25 )
fn show( 250, 265 )
fn show( 1000, 1025 )
2024-11-04 20:28:54 -08:00
2026-02-01 16:33:20 -08:00
handleevents