26 lines
549 B
Text
26 lines
549 B
Text
function nth(atom n)
|
|
sequence suffix
|
|
switch remainder(n, 100) do
|
|
case 11, 12, 13 then
|
|
suffix = "th"
|
|
case else
|
|
switch remainder(n, 10) do
|
|
case 1 then suffix = "st"
|
|
case 2 then suffix = "nd"
|
|
case 3 then suffix = "rd"
|
|
case else suffix = "th"
|
|
end switch
|
|
end switch
|
|
return sprintf("%d%s", {n, suffix})
|
|
end function
|
|
|
|
procedure show_nths(atom start_val, atom end_val)
|
|
for i = start_val to end_val do
|
|
puts(1, nth(i) & ' ')
|
|
end for
|
|
puts(1, '\n')
|
|
end procedure
|
|
|
|
show_nths(1, 25)
|
|
show_nths(250, 265)
|
|
show_nths(1000, 1025)
|