Created
June 14, 2015 23:19
-
-
Save mamonu/32dd5503d4233bf44c63 to your computer and use it in GitHub Desktop.
piglatin function in 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 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