Scratch this question.

I think I've figured out that the "step" function in some people's code is
there for aesthetic reasons only. As long as the step function contains the
same code as would otherwise go directly inside the (lazy-seq ... ) there's
no difference.

That is,

(let [step (fn [a b] <stuff>)]
  (lazy-seq (step a b)))

is the same as

(lazy-seq <stuff>)

The lazy documentation on the web site had made me think there was something
special about the former, i.e. the compiler was optimizing it in some
special way.

Someone please correct me if I'm still confused.

On Sun, Nov 22, 2009 at 6:06 PM, Garth Sheldon-Coulson <[email protected]> wrote:

> Hi All,
>
> I'll confused about the hold-onto-your-head business when building lazy
> seqs using lazy-seq.
>
> The "lazier" documentation on the web site doesn't really clear things up
> for me, though I've read it a few times.
>
> Under what circumstances must one use a "step" function, and under what
> circumstances it it acceptable not to?
>
> If this is covered in depth somewhere other than the "lazier" page please
> feel free just to send a link.
>
> As a point of discussion, does the following function have the potential to
> cause memory problems?
>
> Some notes: *kernel* and *options* are dynamic vars I want the lazy-seq to
> close over. parse-simple-atom is a function for parsing each element
> ("atom," **unrelated to Clojure atoms**) of the coll. type is an arg that is
> used in the parsing of each element of the coll.
>
> (defn parse-expr-coll-to-lazy-seq [coll type]
>     (let [kernel  *kernel*
>                 options *options*]
>         (lazy-seq
>             (binding [*kernel*  kernel
>                                 *options* options]
>                 (when-let [s (seq coll)]
>                     (cons (parse-simple-atom (first s) type)
> (parse-expr-coll-to-lazy-seq (rest s) type)))))))
>
> Thanks,
> Garth
>

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
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

Reply via email to