N'th: Difference between revisions

1,636 bytes added ,  10 years ago
→‎{{header|REXX}}: added the REXX language. -- ~~~~
(→‎{{header|REXX}}: added the REXX language. -- ~~~~)
Line 72:
750'th 751'st 752'nd 753'rd 754'th 755'th 756'th 757'th 758'th 759'th 760'th 761'st 762'nd 763'rd 764'th 765'th 766'th 767'th 768'th 769'th 770'th 771'st 772'nd 773'rd 774'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</pre>
 
=={{header|REXX}}==
<lang rexx>/*REXX pgm displays some ranges of numbers with (th/nd/rd/th) suffixes. */
bot= 0; top= 25; call tell bot,top
bot= 250; top=265; call tell bot,top
bot=1000; top=1025; call tell bot,top
exit /*stick a fork in it, we're done.*/
/*───────────────────────────────────TELL subroutine────────────────────*/
tell: procedure; parse arg L,H; $=
do j=L to H
$=$ j"'" || th(j)
end /*j*/
say 'numbers from ' L " to " H ' (inclusive):'
say strip($)
say
return
/*───────────────────────────────────TH subroutine──────────────────────*/
th: procedure; parse arg x; x=abs(x)
return word('th st nd rd', 1+x//10*(x//100%10\==1)*(x//10<4))</lang>
'''output''' &nbsp; using the default inputs:
<pre>
numbers from 0 to 25 (inclusive):
0'th 1'st 2'nd 3'rd 4'th 5'th 6'th 7'th 8'th 9'th 10'th 11'th 12'th 13'th 14'th 15'th 16'th 17'th 18'th 19'th 20'th 21'st 22'nd 23'rd 24'th 25'th
 
numbers from 250 to 265 (inclusive):
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
 
numbers from 1000 to 1025 (inclusive):
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|Tcl}}==