(take-nth n)
(take-nth n coll)
Returns a lazy seq of every nth item in coll. Returns a stateful
transducer when no collection is provided.
Source
(defn take-nth
"Returns a lazy seq of every nth item in coll. Returns a stateful
transducer when no collection is provided."
{:added "1.0"
:static true}
([n]
(fn [rf]
(let [iv (volatile! -1)]
(fn
([] (rf))
([result] (rf result))
([result input]
(let [i (vswap! iv inc)]
(if (zero? (rem i n))
(rf result input)
result)))))))
([n coll]
(lazy-seq
(when-let [s (seq coll)]
(cons (first s) (take-nth n (drop n s)))))))