Skip to content

Instantly share code, notes, and snippets.

@scudelletti
Last active August 29, 2015 14:16
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 scudelletti/4d6b6056ea7bca78e6df to your computer and use it in GitHub Desktop.
Save scudelletti/4d6b6056ea7bca78e6df to your computer and use it in GitHub Desktop.
Vowel Count using Clojure
(def vowels [\a \e \i \o \u])
(defn convert-to-num [letter]
(if (= (some #{letter} vowels) letter)
1
0)))
(defn count-vowels [phrase]
(reduce + (map convert-to-num (clojure.string/lower-case phrase))))
(count-vowels "Aabc eE")
; 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment