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
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
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,
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
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
> 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
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
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
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)) (