Finish off vector destructuring features.
This commit is contained in:
parent
98b7ab99fe
commit
af19d14c40
@ -4,8 +4,21 @@
|
|||||||
[:foo :bar]))
|
[:foo :bar]))
|
||||||
|
|
||||||
"Whether in function definitions"
|
"Whether in function definitions"
|
||||||
(= "First comes love, then comes marriage, then comes Clojure with the baby carriage"
|
(= (str "First comes love, "
|
||||||
|
"then comes marriage, "
|
||||||
|
"then comes Clojure with the baby carriage")
|
||||||
((fn [[a b c]] __)
|
((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")]
|
||||||
|
__))
|
||||||
|
|
||||||
|
"You can regain the full argument if you like arguing"
|
||||||
|
(= {:original-parts ["Steven" "Hawking"] :named-parts {:first "Steven" :last "Hawking"}}
|
||||||
|
(let [[first-name last-name :as full-name] ["Steven" "Hawking"]]
|
||||||
|
__))
|
||||||
|
|
||||||
)
|
)
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
(ns path-to-answer-sheet
|
(ns path-to-answer-sheet
|
||||||
(:use [path-to-enlightenment :exclude (run)]
|
(:use [path-to-enlightenment :exclude (run)]
|
||||||
[clojure.string :only (join split)]))
|
[clojure.string :only (join split trim)]))
|
||||||
|
|
||||||
(def answers
|
(def answers
|
||||||
{"equalities" {"__" [true
|
{"equalities" {"__" [true
|
||||||
@ -97,7 +97,20 @@
|
|||||||
(recur (dec n) (* acc n))))]
|
(recur (dec n) (* acc n))))]
|
||||||
"___" ['not]}
|
"___" ['not]}
|
||||||
"destructuring" {"__" ["\":bar:foo\""
|
"destructuring" {"__" ["\":bar:foo\""
|
||||||
'(format "First comes %s, then comes %s, then comes %s with the baby carriage" a b c) ]}
|
'(format (str "First comes %s, "
|
||||||
|
"then comes %s, "
|
||||||
|
"then comes %s with the baby carriage")
|
||||||
|
a b c)
|
||||||
|
'(trim
|
||||||
|
(apply str
|
||||||
|
(interleave
|
||||||
|
(apply list
|
||||||
|
first-name
|
||||||
|
last-name
|
||||||
|
(interleave (repeat "aka") aliases))
|
||||||
|
(repeat " "))))
|
||||||
|
'{:original-parts full-name
|
||||||
|
:named-parts {:first first-name :last last-name}} ]}
|
||||||
})
|
})
|
||||||
|
|
||||||
(defn replace-with [s k replacements]
|
(defn replace-with [s k replacements]
|
||||||
|
Loading…
Reference in New Issue
Block a user