Skip to content

Instantly share code, notes, and snippets.

@mwfogleman
Last active August 29, 2015 14:06
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 mwfogleman/71f675d03734212da981 to your computer and use it in GitHub Desktop.
Save mwfogleman/71f675d03734212da981 to your computer and use it in GitHub Desktop.
"Ee' e i:", "Hr's th gst:"
(def vowels "aeiouyAEIOUY")
(def consonants "bcdfghjklmnpqrstvwxzBCDFGHJKLMNPQRSTVWXZ")
(defn alph-filter [sub srn] (clojure.string/capitalize (apply str (remove (set sub) srn))))
(defn self-alph-filter [sub srn] (alph-filter sub (concat "This " srn)))
(def init-one "sentence contains no consonants and the following sentence no vowels.")
(def init-two "sentence contains no vowels and the preceding sentence no consonants.")
(= (self-alph-filter consonants init-one)
"I eee oai o ooa a e ooi eee o oe.")
;; => true
(= (self-alph-filter vowels init-two)
"Ths sntnc cntns n vwls nd th prcdng sntnc n cnsnnts.")
;; => true
;; EE I I!:
(self-alph-filter consonants init-one)
(self-alph-filter vowels init-two)
;; THR SH BLWS!
(some (set consonants) (self-alph-filter consonants init-one)) ; => nil
(some (set vowels) (self-alph-filter vowels init-two)) ; => nil
(= (clojure.set/intersection
(set "Ee' e i:")
(set "Hr's th gst:"))
#{\space \' \:})
;; => true
(= (clojure.set/intersection
(set (alph-filter "': " "Ee' e i:"))
(set (alph-filter "': " "Hr's th gst:")))
#{})
;; => true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment