N'th: Difference between revisions
Content added Content deleted
Simple9371 (talk | contribs) (Added PowerShell) |
(Added Elixir) |
||
Line 537: | Line 537: | ||
250'th 251'st 252'nd 253'rd 254'th 255'th 256'th 257'th 258'th 259'th 260'th 261'st 262'nd 263'rd 264'th 265'th |
250'th 251'st 252'nd 253'rd 254'th 255'th 256'th 257'th 258'th 259'th 260'th 261'st 262'nd 263'rd 264'th 265'th |
||
1000'th 1001'st 1002'nd 1003'rd 1004'th 1005'th 1006'th 1007'th 1008'th 1009'th 1010'th 1011'th 1012'th 1013'th 1014'th 1015'th 1016'th 1017'th 1018'th 1019'th 1020'th 1021'st 1022'nd 1023'rd 1024'th 1025'th</pre> |
1000'th 1001'st 1002'nd 1003'rd 1004'th 1005'th 1006'th 1007'th 1008'th 1009'th 1010'th 1011'th 1012'th 1013'th 1014'th 1015'th 1016'th 1017'th 1018'th 1019'th 1020'th 1021'st 1022'nd 1023'rd 1024'th 1025'th</pre> |
||
=={{header|Elixir}}== |
|||
<lang elixir>defmodule RC do |
|||
def ordinalize(n) do |
|||
num = abs(n) |
|||
ordinal = if rem(num, 100) in 4..20 do |
|||
"th" |
|||
else |
|||
case rem(num, 10) do |
|||
1 -> "st" |
|||
2 -> "nd" |
|||
3 -> "rd" |
|||
_ -> "th" |
|||
end |
|||
end |
|||
"#{n}#{ordinal}" |
|||
end |
|||
end |
|||
Enum.each([0..25, 250..265, 1000..1025], fn range -> |
|||
Enum.map(range, fn n -> RC.ordinalize(n) end) |> Enum.join(" ") |> IO.puts |
|||
end)</lang> |
|||
{{out}} |
|||
<pre> |
|||
0th 1st 2nd 3rd 4th 5th 6th 7th 8th 9th 10th 11th 12th 13th 14th 15th 16th 17th 18th 19th 20th 21st 22nd 23rd 24th 25th |
|||
250th 251st 252nd 253rd 254th 255th 256th 257th 258th 259th 260th 261st 262nd 263rd 264th 265th |
|||
1000th 1001st 1002nd 1003rd 1004th 1005th 1006th 1007th 1008th 1009th 1010th 1011th 1012th 1013th 1014th 1015th 1016th 1017th 1018th 1019th 1020th 1021st 1022nd 1023rd 1024th 1025th |
|||
</pre> |
|||
=={{header|ERRE}}== |
=={{header|ERRE}}== |