RosettaCodeData/Task/Nth/CLU/nth.clu

32 lines
710 B
Plaintext

nth = proc (n: int) returns (string)
num: string := int$unparse(n)
sfx: array[string] := array[string]$[0: "th", "st", "nd", "rd"]
if n / 10 // 10 = 1 cor n // 10 > 3 then
return(num || sfx[0])
else
return(num || sfx[n // 10])
end
end nth
do_range = proc (from, to: int)
po: stream := stream$primary_output()
col: int := 0
for i: int in int$from_to(from,to) do
stream$putleft(po, nth(i), 7)
col := col + 1
if col = 10 then
stream$putc(po, '\n')
col := 0
end
end
stream$putl(po, "\n")
end do_range
start_up = proc ()
do_range(0,25)
do_range(250,265)
do_range(1000,1025)
end start_up