将剩余元素解构为序列

假设你有一个这样的矢量:

(def my-vec [1 2 3 4 5 6])

并且你想要提取前 3 个元素并将剩余元素作为序列。这可以按如下方式完成:

(let [[x y z & remaining] my-vec]
 (println "first:" x ", second:" y "third:" z "rest:" remaining))
;= first: 1 , second: 2 third: 3 rest: (4 5 6)