Infinite series - oliyh/learning-clojure GitHub Wiki
Be warned - evaluating these expressions as-is could crash your REPL. You're advised to use take to view the first n elements!
Range
Returns a sequence of all the numbers in a given range. Step size can be optionally specified (defaults to 1)
(range 0) ;; (0 1 2 3 4 5 ...)
(range 0 100) (0 1 2 3 4 5 ... 100)
(range 0 100 2) ;; (0 2 4 6 8 10 ... 100)
Repeat
Returns a sequence of the same value again and again and again and again...
(repeat 1) ;; (1 1 1 1 1 ...)
Iterate
Returns a sequence of x, (f x), (f (f x)), (f (f (f x))) ...
(iterate inc 0) ;; (0 1 2 3 4 5)
(iterate #(* 2 %) 1) ;; (1 2 4 8 16 ...)