Created
April 3, 2014 23:43
-
-
Save abscondment/9965125 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(defn cap-first [s] | |
(loop [[w & words] (re-seq #"[^ ]+[ ]*" s) | |
res '()] | |
(if (nil? w) (clojure.string/join (reverse res)) | |
(let [W (clojure.string/capitalize w)] | |
(if (not= w W) | |
(str (clojure.string/join (reverse res)) | |
W | |
(clojure.string/join words)) | |
(recur words (conj res w))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Wow. That's harder to read than the Haskell! I need to work on my clojure maybe.