Last active
August 29, 2015 14:16
-
-
Save scudelletti/4d6b6056ea7bca78e6df to your computer and use it in GitHub Desktop.
Vowel Count using Clojure
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
(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