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)) (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 produce f(x) f(f(x)) f(f(f(x))) ... then check
> out iterate.
>
> On Sat, Nov 15, 2008 at 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
> > (index-fn-seq f initial [n]); returns ((f i) (f (inc i)) (f (inc
> > (inc i))) ...) to i = n or infinity
>
> > I couldn't find either in the docs. Are either of these included in
> > Clojure, and if not, is there a way to create them?
>
> > Thanks for your answers?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---