Problem
Trolls are attacking your comment section!
A common way to deal with this situation is to remove all of the vowels from the trolls' comments, neutralizing the threat.
Your task is to write a function that takes a string and return a new string with all vowels removed.
For example, the string “This website is for losers LOL!” would become “Ths wbst s fr lsrs LL!”.
Solution
Solution 1
(defn disemvowel
[string]
(reduce (fn [result next]
(if (#{\A \E \I \O \U \a \e \i \o \u} next)
result
(str result next)))
""
string))
Solution 2
(defn disemvowel
[string]
(apply str (remove (set "AEIOUaeiou") string)))
Share this post
Twitter
Google+
Facebook
Reddit
LinkedIn
StumbleUpon
Email