RosettaCodeData/Task/Nth/Fennel/nth.fennel

15 lines
321 B
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))))