Thanks for your answers. iterate was just what I needed.
On Nov 15, 9:30 am, "Craig Andera" <[EMAIL PROTECTED]> wrote:
> One way to lazily produce f(n) over an infinite number of integers is
> using map to apply your function to an infinite (lazy) series of
> integers:
>
> (map (fn [x] (* x 3)) (
On Nov 15, 11:15 am, samppi <[EMAIL PROTECTED]> wrote:
> Is there a way to make a lazy sequence whose sequential values are
> derived from some function? I'm thinking about two ways:
>
> (recursive-fn-seq f initial [n]) ; returns (initial (f initial) (f
> (f initial)) ...) n or infinity times
One way to lazily produce f(n) over an infinite number of integers is
using map to apply your function to an infinite (lazy) series of
integers:
(map (fn [x] (* x 3)) (iterate inc 0))
=> (0 3 6 9 ...)
Although you'd be wise to use take when evaluating this in the REPL.
If you want to instead pr
Is there a way to make a lazy sequence whose sequential values are
derived from some function? I'm thinking about two ways:
(recursive-fn-seq f initial [n]) ; returns (initial (f initial) (f
(f initial)) ...) n or infinity times
(index-fn-seq f initial [n]); returns ((f i) (f (inc i)) (f