Last active
August 29, 2015 14:00
-
-
Save jessitron/11201765 to your computer and use it in GitHub Desktop.
The threading macro lets us define functions ABOUT data instead of making methods on classes, while still using a top-down ordering of code.
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 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