### Destructuring Destructuring
(deconstruct binding-form & {:keys [as-map]})
Returns symbols bound in a binding form, either as a flat sequence
and in the same order as in the binding form, or as a map if the
:as-map
option is set.
(deconstruct '[a & {:keys [x] y :_y :or {x 1} :as m}])
;; => '[a x y m]
(deconstruct '[a & {:keys [x] y :_y :or {x 1} :as m}] :as-map true)
;; => '{:a a :x x :y y :m m}
Returns symbols bound in a binding form, either as a flat sequence and in the same order as in the binding form, or as a map if the `:as-map` option is set. ```clojure (deconstruct '[a & {:keys [x] y :_y :or {x 1} :as m}]) ;; => '[a x y m] (deconstruct '[a & {:keys [x] y :_y :or {x 1} :as m}] :as-map true) ;; => '{:a a :x x :y y :m m} ```
(disentangle binding-form)
Parses one level of destructuring.
(disentangle '[a b & [c]])
=> '{:items [a b], :more [c]}
(disentangle '{:keys [a] b :b [c1 c2] :c :or {d 1} :as m})
=> '{:items [a b [c1 c2]],
:as m,
:or {d 1},
:mapping {a :a, b :b, [c1 c2] :c}}
Parses one level of destructuring. ```clojure (disentangle '[a b & [c]]) => '{:items [a b], :more [c]} (disentangle '{:keys [a] b :b [c1 c2] :c :or {d 1} :as m}) => '{:items [a b [c1 c2]], :as m, :or {d 1}, :mapping {a :a, b :b, [c1 c2] :c}} ```
(efface binding-form & syms)
Removes given symbols from a binding form.
(efface '[a & more :as all] 'more 'all) ;; => '[a]
(efface '[[a b] & more :as all] '[a all]) ;; => '[[b] & more]
(efface '{:keys [a] b :b :or {a 1} :as all} 'a) ;; => '{b :b :as all}
Removes given symbols from a binding form. ```clojure (efface '[a & more :as all] 'more 'all) ;; => '[a] (efface '[[a b] & more :as all] '[a all]) ;; => '[[b] & more] (efface '{:keys [a] b :b :or {a 1} :as all} 'a) ;; => '{b :b :as all} ```
(efface-except binding-form & syms)
Similarly to efface
, removes all but the given syms from the
binding form.
Similarly to [[efface]], removes all but the given syms from the binding form.
(entangle m)
Undoes what disentangle
does.
(entangle '{:items [a b]})
;; => [a b]
(entangle '{:items [a b] :or {b 1}, :mapping {a :a b :b}})
;; => {a :a, b :b, :or {b 1}}
Undoes what [[disentangle]] does. ```clojure (entangle '{:items [a b]}) ;; => [a b] (entangle '{:items [a b] :or {b 1}, :mapping {a :a b :b}}) ;; => {a :a, b :b, :or {b 1}} ```
(restructure binding-form mapping)
Undoes what [[destructure]] does.
(restructure '[x & {:keys [a b] c :cc d :d :or {d 3}}]
'{x 0 a 1 b 2 c 3})
(restructure '[x & {:keys [a b] c :cc d :d :or {d 3}}]
{:x 0 :a 1 :b 2 :c 3})
(restructure '[x & {:keys [a b] c :cc d :d :or {d 3}}]
'[x 0 a 1 b 2 c 3])
;; => [0 :a 1 :b 2 :cc 3 :d nil]
Undoes what [[destructure]] does. ```clojure (restructure '[x & {:keys [a b] c :cc d :d :or {d 3}}] '{x 0 a 1 b 2 c 3}) (restructure '[x & {:keys [a b] c :cc d :d :or {d 3}}] {:x 0 :a 1 :b 2 :c 3}) (restructure '[x & {:keys [a b] c :cc d :d :or {d 3}}] '[x 0 a 1 b 2 c 3]) ;; => [0 :a 1 :b 2 :cc 3 :d nil] ```
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close