N'th: Difference between revisions

1,970 bytes added ,  1 month ago
m
fix typo
mNo edit summary
m (fix typo)
 
(3 intermediate revisions by 2 users not shown)
Line 2,433:
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|Fennel}}==
{{trans|Lua}}
 
<syntaxhighlight lang="fennel">
(fn get-suffix [n]
(let [last-two (% n 100)
last-one (% n 10)]
(if (and (> last-two 3) (< last-two 21)) :th
(= last-one 1) :st
(= last-one 2) :nd
(= last-one 3) :rd
:th)))
 
(fn nth [n]
(.. n "'" (get-suffix n)))
 
(for [i 0 25]
(print (nth i) (nth (+ i 250)) (nth (+ i 1000))))
</syntaxhighlight>
 
{{out}}
Same as [[#Lua|Lua]].
 
=={{header|Forth}}==
Line 4,044 ⟶ 4,067:
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|Refal}}==
<syntaxhighlight lang="refal">$ENTRY Go {
= <Show 0 25>
<Show 250 265>
<Show 1000 1025>;
};
 
Nth {
s.N, <Symb s.N>: {
e.X '1' s.Y = e.X '1' s.Y 'th';
e.X '1' = e.X '1st';
e.X '2' = e.X '2nd';
e.X '3' = e.X '3rd';
e.X = e.X 'th';
};
};
 
Cell {
s.N, <First 8 <Nth s.N> ' '>: (e.1) e.2 = e.1;
}
 
Group {
s.N e.1 = <Group (s.N s.N) () e.1>;
(s.N s.M) (e.1) = (e.1);
(s.N 0) (e.1) e.2 = (e.1) <Group (s.N s.N) () e.2>;
(s.N s.M) (e.1) s.2 e.3 = <Group (s.N <- s.M 1>) (e.1 s.2) e.3>;
};
 
Iota {
s.End s.End = s.End;
s.Start s.End = s.Start <Iota <+ s.Start 1> s.End>;
};
 
Each {
s.F = ;
s.F t.I e.X = <Mu s.F t.I> <Each s.F e.X>;
};
 
ShowLine {
(e.Line) = <Prout <Each Cell e.Line>>;
};
 
Show {
s.Start s.End,
<Iota s.Start s.End>: e.Range,
<Group 10 e.Range>: e.Lines
= <Prout <Each ShowLine e.Lines>>;
};</syntaxhighlight>
{{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|REXX}}==
2,094

edits