1.3.0 permalink Arrow_down_16x16

nthrest

clojure.core

  • (nthrest coll n)
Returns the nth rest of coll, coll when n is 0.

1 Example top

  • user=> (nthrest (range 10) 5)
    (5 6 7 8 9)
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:2755 top

(defn nthrest
  "Returns the nth rest of coll, coll when n is 0."
  {:added "1.3"
   :static true}
  [coll n]
    (loop [n n xs coll]
      (if (and (pos? n) (seq xs))
        (recur (dec n) (rest xs))
        xs)))
Vars in clojure.core/nthrest:
Used in 0 other vars

Comments top

1 comment(s) for nthrest.

This differs from clojure.core/drop in that it immediately drops the head of the seq, instead of doing so on the first call to first or seq.

Log in to add a comment.