You're viewing version 1.2.0 of rest. The latest stable version of Clojure Core is 1.3.0.
1.2.0 Arrow_down_16x16
  • (rest coll)
Returns a possibly empty seq of the items after the first. Calls seq on its
argument.

5 Examples top

  • user=> (rest [1 2 3 4 5])
    (2 3 4 5)
    user=> (rest ["a" "b" "c" "d" "e"])
    ("b" "c" "d" "e")
  • user=> (rest '())
    ()
  • user=> (rest nil)
    ()
  • ;; A simple implementation using rest for recursing over a collection.  Note that (seq coll) is used as the test.
    (defn my-map [func coll]
         (when-let [s (seq coll)]
            (cons (func (first s))
    	      (my-map func (rest s)))))
  • user=>(rest '(1 2 3 4 5))
    '(2 3 4 5)
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:63 top

(def
 ^{:arglists '([coll])
   :tag clojure.lang.ISeq
   :doc "Returns a possibly empty seq of the items after the first. Calls seq on its
  argument."
   :added "1.0"}  
 rest (fn rest [x] (. clojure.lang.RT (more x))))
Vars in clojure.core/rest: fn

Comments top

1 comment(s) for rest.

rest is generally preferred over next. See the Clojure.org documentation on writing lazy functions.

Also, the topic is covered on StackOverflow.com: rest vs. next.

Log in to add a comment.