& rest

special charactersince v0.0-927 in clojureEdit

A concept shared between destructure [] and fn for binding the rest of the values of a sequence to a name.

  • (fn [... & rest]) - for function arguments
  • (let [[... & rest] ...]) - for sequences

Examples:

Binding c to the rest of the function arguments:

(defn foo
  [a b & c]
  c)
(foo 1 2 3 4)
;;=> (3 4)

Binding c to the rest of the destructured values:

(let [[a b & c]
      [1 2 3 4]]
  c)
;;=> (3 4)