解构还使您能够将序列解释为图:
(def my-vec [:a 1 :b 2]) (def my-lst '("smthg else" :c 3 :d 4)) (let [[& {:keys [a b]}] my-vec [s & {:keys [c d]} my-lst] (+ a b c d)) ;= 10
这对于使用命名参数定义函数很有用:
(defn my-func [a b & {:keys [c d] :or {c 3 d 4}}] (println a b c d)) (my-func 1 2) ;= 1 2 3 4 (my-func 3 4 :c 5 :d 6) ;= 3 4 5 6