takenth  Clojure Standard Library
For a quick intro to this series of blog posts check out Clojure Standard Library  Intro. It includes a lot of useful info, including notes about presentation of examples and more.
This posts function:
takenth
Quick Overview
Description
clojure.core/takenth
is a function that accepts a collection and returns every nth item in that collection.
Example
In this example I am going to use takenth
to get every third number from a collection that contains numbers 0 up to 20 (exclusive). The collection of numbers will be generated using range
(takenth 3 (range 20))
; => (0 3 6 9 12 15 18) ; Every third number from range(20).
How To Use
Parameters and Return Values
takenth
is a multiple arity function and uses arity overloading in order to provide different behavior based on the number of arguments you provide. takenth
takes one to two arguments.

(takenth n)
Providing onlyn
, returns a stateful transducer. 
(takenth n coll)
Providing bothn
and a collection (coll
), returns a lazy sequence that contains every nth item fromcoll
.
Note: Nonpositive integers and zero return an infinite lazy sequence of zeros. ^{1}
Example Use Cases
One possible use might be to use takenth to do a quick, naive downsample of a stream of data. If in the stream, items close together are likely to contain similar information or, if it is already random.
Ex: ^{2}
(def randomstream (repeatedly #(randint 20))) ; Created an infinite stream of random integers
; => #'user/randomstream
(def sample (takenth 20 randomstream)) ; Created a sample of randomstream; contains every 20th integer.
; => #'user/sample
(take 10 sample)
; => (19 14 5 3 12 10 13 15 2 14) ; The first ten items from sample.

http://clojuredocs.org/clojure.core/takenth#example555dfc57e4b03e2132e7d169 ↩︎

Checkout posts on
repeatedly
,randint
andtake
. ↩︎