Skip to content

Instantly share code, notes, and snippets.

@tfrisk-old
Created May 15, 2015 13:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tfrisk-old/27ba1ef9b59316aaaa94 to your computer and use it in GitHub Desktop.
Save tfrisk-old/27ba1ef9b59316aaaa94 to your computer and use it in GitHub Desktop.
Clojurebridge snippets
; ---------------------------------------------------
; https://github.com/ClojureBridge/curriculum/blob/master/outline/flow_control.md
(defn ordinal [n]
(let [r (rem n 10)]
(if (and (> n 10) (< n 15))
(str n "th")
(if (= r 1)
(str n "st")
(if (= r 2)
(str n "nd")
(if (= r 3)
(str n "rd")
(str n "th")))))))
(ordinal 1)
(ordinal 2)
(ordinal 3)
(ordinal 4)
(ordinal 5)
(ordinal 10)
(ordinal 11)
(ordinal 12)
(ordinal 13)
(ordinal 14)
(ordinal 15)
(ordinal 21)
(ordinal 22)
(ordinal 23)
; ---------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment