Remove last vowel from words in a sentence
Write a function that removes the last vowel from every word in a sentence. You can split words by spaces. Vowels are a, e, i, o, and u.
Examples:
(remove-last-vowels "Hi, there!") ;=> "H, ther!"
(remove-last-vowels "This is not a test.") ;=> "Ths s nt tst."
(remove-last-vowels "Hippopotamus") ;=> "Hippopotams"
Thanks to this site for the idea. This is kind of a silly one, but I thought it would be good for testing our Clojure skills.
You can leave comments on these submissions in the gist itself. Please leave comments! You can also hit the Subscribe button to keep abreast of the comments. We’re all here to learn.
Kenny Shen, Viktor P
You can use a set as a function:
(#{\a} \a) ; => \a (truthy)
(#{\a} \b) ; => nil (falsey)
If you know your set does not contain false or nil (
(#{false} false) ; => false
, whereas(contains? #{false} false) ; => true
), you do not needcontains?
.Viktor P
Check out complement. You could refactor to
(def not-vowel? (complement vowel?))