On Nov 17, 4:25 pm, Bradbev <[EMAIL PROTECTED]> wrote:
> On Nov 17, 3:50 pm, Adam Jones <[EMAIL PROTECTED]> wrote:
>
> > On Nov 17, 3:26 pm, Robert Ewald <[EMAIL PROTECTED]> wrote:
>
> > > Hello,
>
> > > Doing some small experiments I stumbled over map returning a lazy seq 
> > > instead
> > > of performing the function. I had to convert that to a doseq. Is there any
> > > rationale for not having an eager map. Or was I just not reading the docs
> > > properly?
>
> > Many of Clojure's functions that operate on seqs have this property.
> > The idea is to capture the space efficiency of lazy list processing by
> > default. If you really need strict evaluation, wrap the map with
> > doall. I'm guessing that strict equivalents aren't provided to
> > encourage the use of the lazy functions unless they absolutely aren't
> > needed.
>
> What is the preferred idiom for converting from a Lazy seq to a proper
> seq?
> I've been using (into [] (map .....)).
> doall and dorun don't really appeal to me in this usage, because to me
> they say "This code is lazy and I'm executing it for side effects, not
> results".  (into []...) says to me "This code is lazy, and I really
> want a concrete vector here.
>
> Thoughts?

This is true for dorun, but not exactly for doall. (For instance,
there's no difference in the result between (into '() ...) and
(doall ...)) I'm not really confident enough to speculate on the
relative efficiency of either. As far as I have seen, there is no
preferred idiom for forcing the thunks in a seq.

I'm in the middle of writing some code to extract sql results, which
means I'm doing a *lot* of forcing right now. It's almost enough for
me to wish there was a convention (and provided definitions) for
denoting lazy/strict versions of functions. (e.g. (map f ...) is a
lazy seq, (map! f ...) is strict)

-Adam

>
> Cheers,
> Brad
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To post to this group, send email to clojure@googlegroups.com
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