You're viewing version 1.2.0 of nthnext. The latest stable version of Clojure Core is 1.3.0.
1.2.0 Arrow_down_16x16

nthnext

clojure.core

  • (nthnext coll n)
Returns the nth next of coll, (seq coll) when n is 0.

1 Example top

  • user=> (nthnext (range 10) 3)
    (3 4 5 6 7 8 9)
    
    user=> (nthnext [] 3)
    nil
    
    
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:3393 top

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

Comments top

1 comment(s) for nthnext.

nthnext is similar to drop. But nthnext is eager, while drop is lazy.

Also parameters are in opposite order.

Log in to add a comment.