將剩餘元素解構為序列
假設你有一個這樣的向量:
(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)
假設你有一個這樣的向量:
(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)