fork download
  1. (defn disemvowler [input]
  2. (loop [letter (first input)
  3. cnsnnts []
  4. vowels []
  5. remaining (rest input)]
  6. (if letter
  7. (case letter
  8. (\a \A \e \E \i \I \o \O \u \U) (recur (first remaining) cnsnnts (conj vowels letter) (rest remaining))
  9. \space (recur (first remaining) cnsnnts vowels (rest remaining))
  10. (recur (first remaining) (conj cnsnnts letter) vowels (rest remaining)))
  11. {:consonants cnsnnts :vowels vowels})))
  12.  
  13. (defn disemvowler2 [input]
  14. {:consonants (clojure.string/join (re-seq #"[^aeiouAEIOU ]" input)) :vowels (clojure.string/join (re-seq #"[aeiouAEIOU]" input))})
  15.  
  16. (println (disemvowler "all those who believe in psychokinesis raise my hand"))
  17. (println (disemvowler2 "all those who believe in psychokinesis raise my hand"))
Success #stdin #stdout 1.4s 389120KB
stdin
Standard input is empty
stdout
{:consonants [l l t h s w h b l v n p s y c h k n s s r s m y h n d], :vowels [a o e o e i e e i o i e i a i e a]}
{:consonants llthswhblvnpsychknssrsmyhnd, :vowels aoeoeieeioieiaiea}