N'th: Difference between revisions
Content added Content deleted
m (Corrected Forth code to produce 1011th, 1012th,1013th instead of 1011st, 1012nd, 1013rd) |
|||
Line 1,825: | Line 1,825: | ||
<syntaxhighlight lang="forth">: 'nth ( -- c-addr ) s" th st nd rd th th th th th th " drop ; |
<syntaxhighlight lang="forth">: 'nth ( -- c-addr ) s" th st nd rd th th th th th th " drop ; |
||
: .nth ( n -- ) |
: .nth ( n -- ) |
||
dup 10 20 within if 0 .r ." th " exit then |
dup 100 mod 10 20 within if 0 .r ." th " exit then |
||
dup 0 .r 10 mod 3 * 'nth + 3 type ; |
dup 0 .r 10 mod 3 * 'nth + 3 type ; |
||
Line 1,849: | Line 1,849: | ||
1000th 1001st 1002nd 1003rd 1004th |
1000th 1001st 1002nd 1003rd 1004th |
||
1005th 1006th 1007th 1008th 1009th |
1005th 1006th 1007th 1008th 1009th |
||
1010th |
1010th 1011th 1012th 1013th 1014th |
||
1015th 1016th 1017th 1018th 1019th |
1015th 1016th 1017th 1018th 1019th |
||
1020th 1021st 1022nd 1023rd 1024th |
1020th 1021st 1022nd 1023rd 1024th |
||
1022th ok</pre> |
|||
=={{header|Fortran}}== |
=={{header|Fortran}}== |