Binding forms can pull a collection apart. In a vector binding, & gathers whatever is left.
&
(let [[a b & more] [1 2 3 4]] (println a b more))
Map binding with :keys binds locals from keyword entries. :or supplies defaults. A function parameter can destructure the same way.
:keys
:or
(let [{:keys [name city] :or {city "unknown"}} {:name "Ada"}] (println name city)) (defn area [{:keys [w h]}] (* w h)) (println (area {:w 3 :h 4}))
The same forms work in let and in parameter lists.
let
$ glj destructuring.glj 1 2 (3 4) Ada unknown 12
Next example: Variadic Functions.
A hands-on tour in the style of Go by Example. Glojure is a Clojure interpreter hosted on Go.