take-nth

clojure.core

  • (take-nth n coll)
Returns a lazy seq of every nth item in coll.

1 Example top

  • user=> (take-nth 2 (range 10))
    (0 2 4 6 8)
    
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:3811 top

(defn take-nth
  "Returns a lazy seq of every nth item in coll."
  {:added "1.0"
   :static true}
  [n coll]
    (lazy-seq
     (when-let [s (seq coll)]
       (cons (first s) (take-nth n (drop n s))))))
Vars in clojure.core/take-nth:
Used in 0 other vars

Comments top

No comments for take-nth. Log in to add a comment.