Name

iterate

Usage

builtin-function

Syntax

(iterate func initial-value)

Description

Returns an infinite sequence with initial-value as its first element. The next element is the result of calling func with the previous element as the argument.

user > (take 10 (iterate inc 1))
it: (1 2 3 4 5 6 7 8 9 10)
user > (take 10 (iterate - 1))
it: (1 -1 1 -1 1 -1 1 -1 1 -1)