Skip to content

Instantly share code, notes, and snippets.

@tfrisk-old
Created May 15, 2015 13:20
Show Gist options
  • Select an option

  • Save tfrisk-old/27ba1ef9b59316aaaa94 to your computer and use it in GitHub Desktop.

Select an option

Save tfrisk-old/27ba1ef9b59316aaaa94 to your computer and use it in GitHub Desktop.

Revisions

  1. @tfrisk tfrisk created this gist May 15, 2015.
    29 changes: 29 additions & 0 deletions gistfile1.clj
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    ; ---------------------------------------------------
    ; 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)
    ; ---------------------------------------------------