Last active
December 12, 2015 02:49
-
-
Save jbrechtel/4702246 to your computer and use it in GitHub Desktop.
clojure example
This file contains 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
(defn add-prefix [prefix string] | |
"Prepends prefix to string separated by a space" | |
(str prefix " " string)) | |
(def formalize-male | |
"Returns a formal version of a male name" | |
(partial add-prefix "Mr")) | |
(defn parenthesize [string] | |
"Wraps names in parentheses" | |
(str "(" string ")")) | |
(def guys ["James" "Pat" "Phil" "Tom"]) | |
;say I want to formalize and wrap in parens each name | |
;then print out the results for inspection | |
(println (map (comp parenthesize formalize-male) guys)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment