Skip to content

Instantly share code, notes, and snippets.

@abscondment
Created April 3, 2014 23:43
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 abscondment/9965125 to your computer and use it in GitHub Desktop.
Save abscondment/9965125 to your computer and use it in GitHub Desktop.
(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)))))))
@jessitron
Copy link

Wow. That's harder to read than the Haskell! I need to work on my clojure maybe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment