Returns a seq of the items after the first. Calls seq on its argument. If there are no more items, returns nil.
user=> (next '(:alpha :bravo :charlie)) (:bravo :charlie) user=> (next (next '(:one :two :three))) (:three) user=> (next (next (next '(:one :two :three)))) nil
;; next is used in the recursive call. (This is a naive implementation for illustration only. Using `rest` is usually preferred over `next`.) (defn my-map [func a-list] (when a-list (cons (func (first a-list)) (my-map func (next a-list)))))
;; Difference between next and rest: (next [:a]) ;; => nil (rest [:a]) ;; => () (next []) ;; => nil (rest []) ;; => () (next nil) ;; => nil (rest nil) ;; => ()
Returns a possibly empty seq of the items after the first. Calls seq on its argument.
Returns the first item in the collection. Calls seq on its argument. If coll is nil, returns nil...
Same as (first (next x))
Returns the nth rest of coll, coll when n is 0.
Returns the nth next of coll, (seq coll) when n is 0.
(next aseq) === (seq (rest aseq))
When writing lazy sequence functions, you should use rest, not next.