Skip to content

Instantly share code, notes, and snippets.

@mamonu
Created June 14, 2015 23:19
Show Gist options
  • Select an option

  • Save mamonu/32dd5503d4233bf44c63 to your computer and use it in GitHub Desktop.

Select an option

Save mamonu/32dd5503d4233bf44c63 to your computer and use it in GitHub Desktop.
piglatin function in clojure ;)
(def vowel? (set "aeiou")) ; sets are functions of their items (to test contains)
(defn pig-latin [word]
; word is expected to be a string
; which can be treated like a sequence of characters.
(let [first-letter (first word)] ; assigns a local variable
(if (vowel? first-letter)
(str word "ay") ; then part of if
(str (subs word 1) first-letter "ay")))) ; else part of if
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment