Skip to content

Instantly share code, notes, and snippets.



Last active Aug 29, 2015
What would you like to do?
The threading macro lets us define functions ABOUT data instead of making methods on classes, while still using a top-down ordering of code.
(defn addCustomer [sale, cust] (assoc sale :customer cust))
(defn addItems [sale, items] (assoc sale :items items))
(defn complete [sale, num] (println "Sale" num ": selling" (:items sale) "to" (:customer sale)))
(def sale { :store "Downtown" })
(-> sale
(addCustomer "Fred")
(addItems ["carrot", "eggs"])
(complete 100)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment