Re: Observations about new lazy branch

2009-03-01 Thread Rich Hickey
On Feb 28, 2009, at 6:25 PM, Mark Engelberg wrote: > > On Sat, Feb 28, 2009 at 6:09 AM, Rich Hickey > wrote: >> I think your fundamental hangup is on looking at (rest x) as a >> calculation/effect triggered by a consumer. (rest x) is logically >> just >> a slot lookup that obtains another s

Re: Observations about new lazy branch

2009-02-28 Thread Mark Engelberg
On Sat, Feb 28, 2009 at 6:09 AM, Rich Hickey wrote: > Clojure's fully-lazy now pretty much follows the "even" model > described by Wadler: > > How to add laziness to a strict language without even being odd: > > http://homepages.inf.ed.ac.uk/wadler/papers/lazyinstrict/lazyinstrict.ps OK, I just

Re: Observations about new lazy branch

2009-02-28 Thread Mark Engelberg
On Sat, Feb 28, 2009 at 6:09 AM, Rich Hickey wrote: > I think your fundamental hangup is on looking at (rest x) as a > calculation/effect triggered by a consumer. (rest x) is logically just > a slot lookup that obtains another seq. The laziness of that seq is > its constructor's problem. Right,

Re: Observations about new lazy branch

2009-02-28 Thread Rich Hickey
On Feb 27, 2009, at 11:10 PM, Mark Engelberg wrote: > > I just finished porting my combinatorics code to the new lazy > constructs, and I discovered some subtleties to using lazy-seq that > were not at first apparent. > > To begin with, consider the two versions of map: > The old way: > > (defn

Re: Observations about new lazy branch

2009-02-28 Thread Christophe Grand
Mark Engelberg a écrit : > Let's imagine that you are using map on a collection for which it is > very computation intensive to generate the rest, but trivial to > generate the first. > I don't think that's that simple: it depends on what is in the cons. For example, if the input seq is the r

Re: Observations about new lazy branch

2009-02-27 Thread Jason Wolfe
> I'm not sure which old-map you mean here. If you mean the old > lazy-cons version, using your above macro, this will have too many > lazy-seq calls. Yeah, you're right ... I managed to confuse myself. Off the top of my head I can't think of a nicer way to write lazier- map than what you'v

Re: Observations about new lazy branch

2009-02-27 Thread Mark Engelberg
On Fri, Feb 27, 2009 at 8:33 PM, Jason Wolfe wrote: > > If lazy-cons makes your life easier, I think you can still have > something very much like it: > > (defmacro lazy-cons [x s] >  `(lazy-seq (cons ~x (lazy-seq ~s As you pointed out, in most contexts, this will double the number of lazy-s

Re: Observations about new lazy branch

2009-02-27 Thread Jason Wolfe
If lazy-cons makes your life easier, I think you can still have something very much like it: (defmacro lazy-cons [x s] `(lazy-seq (cons ~x (lazy-seq ~s If you're interested in perf, you'd just have to write your code a bit carefully to avoid double lazy-seq'ing the rests: (defn map [f col

Observations about new lazy branch

2009-02-27 Thread Mark Engelberg
I just finished porting my combinatorics code to the new lazy constructs, and I discovered some subtleties to using lazy-seq that were not at first apparent. To begin with, consider the two versions of map: The old way: (defn map ([f coll] (when (seq coll) (lazy-cons (f (first coll)) (