|
|
|
@ -6,19 +6,19 @@
|
|
|
|
|
(meditations
|
|
|
|
|
"Destructuring is an arbiter: it breaks up arguments"
|
|
|
|
|
(= __ ((fn [[a b]] (str b a))
|
|
|
|
|
[:foo :bar]))
|
|
|
|
|
[:foo :bar]))
|
|
|
|
|
|
|
|
|
|
"Whether in function definitions"
|
|
|
|
|
(= (str "First comes love, "
|
|
|
|
|
"then comes marriage, "
|
|
|
|
|
"then comes Clojure with the baby carriage")
|
|
|
|
|
((fn [[a b c]] __)
|
|
|
|
|
["love" "marriage" "Clojure"]))
|
|
|
|
|
["love" "marriage" "Clojure"]))
|
|
|
|
|
|
|
|
|
|
"Or in let expressions"
|
|
|
|
|
(= "Rich Hickey aka The Clojurer aka Go Time aka Macro Killah"
|
|
|
|
|
(let [[first-name last-name & aliases]
|
|
|
|
|
(list "Rich" "Hickey" "The Clojurer" "Go Time" "Macro Killah")]
|
|
|
|
|
(list "Rich" "Hickey" "The Clojurer" "Go Time" "Macro Killah")]
|
|
|
|
|
__))
|
|
|
|
|
|
|
|
|
|
"You can regain the full argument if you like arguing"
|
|
|
|
@ -29,14 +29,13 @@
|
|
|
|
|
"Break up maps by key"
|
|
|
|
|
(= "123 Test Lane, Testerville, TX"
|
|
|
|
|
(let [{street-address :street-address, city :city, state :state} test-address]
|
|
|
|
|
__))
|
|
|
|
|
__))
|
|
|
|
|
|
|
|
|
|
"Or more succinctly"
|
|
|
|
|
(= "123 Test Lane, Testerville, TX"
|
|
|
|
|
(let [{:keys [street-address __ __]} test-address]
|
|
|
|
|
__))
|
|
|
|
|
__))
|
|
|
|
|
|
|
|
|
|
"All together now!"
|
|
|
|
|
(= "Test Testerson, 123 Test Lane, Testerville, TX"
|
|
|
|
|
(___ ["Test" "Testerson"] test-address))
|
|
|
|
|
)
|
|
|
|
|
(___ ["Test" "Testerson"] test-address)))
|
|
|
|
|