Created
May 15, 2015 13:20
-
-
Save tfrisk-old/27ba1ef9b59316aaaa94 to your computer and use it in GitHub Desktop.
Clojurebridge snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
; --------------------------------------------------- | |
; 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