Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
12
Task/Nth/Standard-ML/nth.ml
Normal file
12
Task/Nth/Standard-ML/nth.ml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
local
|
||||
val v = Vector.tabulate (10, fn 1 => "st" | 2 => "nd" | 3 => "rd" | _ => "th")
|
||||
fun getSuffix x =
|
||||
if 3 < x andalso x < 21 then "th" else Vector.sub (v, x mod 10)
|
||||
in
|
||||
fun nth n =
|
||||
Int.toString n ^ getSuffix (n mod 100)
|
||||
end
|
||||
|
||||
(* some test ouput *)
|
||||
val () = (print o concat o List.tabulate)
|
||||
(26, fn i => String.concatWith "\t" (map nth [i, i + 250, i + 1000]) ^ "\n")
|
||||
Loading…
Add table
Add a link
Reference in a new issue