Skip to content

Instantly share code, notes, and snippets.

@jbrechtel
Last active December 12, 2015 02:49
Show Gist options
  • Save jbrechtel/4702246 to your computer and use it in GitHub Desktop.
Save jbrechtel/4702246 to your computer and use it in GitHub Desktop.
clojure example
(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