Hi,
Am Mittwoch, 1. August 2012 14:21:22 UTC+2 schrieb Vinay D.E:
>
> Just curious, but if I chained a large number of such lazy constructs,
> isn't there danger of a big unpredictable spike in CPU / Memory if
> something deeply nested is accessed ?
>
You may run into a stackoverflow, though. T
On Wed, Aug 1, 2012 at 5:21 AM, Vinay D.E wrote:
> Just curious, but if I chained a large number of such lazy constructs, isn't
> there danger of a big unpredictable spike in CPU / Memory if something
> deeply nested is accessed ?
Not really any more than if evaluation were eager and it was all
c
Hi,
Am Mittwoch, 1. August 2012 14:21:22 UTC+2 schrieb Vinay D.E:
>
>
> Just curious, but if I chained a large number of such lazy constructs,
> isn't there danger of a big unpredictable spike in CPU / Memory if
> something deeply nested is accessed ?
> Is there someplace where this is discussed
Just pay attention that when using later elements you don't need the
earlier elements, and you should be fine. (IIRC)
2012/8/1 Vinay D.E :
> Thanks Sean & Carlo for the detailed comments!
> The gap in my understanding was exactly *how* lazy 'lazy evaluation' is, so
> the evaluation of 'i' is defer
Thanks Sean & Carlo for the detailed comments!
The gap in my understanding was exactly *how* lazy 'lazy evaluation' is, so
the evaluation of 'i' is deferred until it is totally unavoidable.
Just curious, but if I chained a large number of such lazy constructs,
isn't there danger of a big unpredi
On Mon, Jul 30, 2012 at 11:05 PM, Vinay D.E wrote:
> I tried putting a print and it works as expected.
Because you are realizing the whole of i to print it.
> 1) I assumed that printing out [i @a] instead of [@a i] should realize 'i'
No, [i @a] creates a two-element vector of a lazy-seq and a v
> 1) I assumed that printing out [i @a] instead of [@a i] should realize 'i'
> first and @a should be correctly displayed as 5. This does not happen, it
> simply prints [(1 2 3 4 5) 0] if the order is reversed.
So, this evaluates in two "stages".
First the terms `i` and `@a` are evaluated to get
Hi Evan,
Thanks for the reply.
I tried putting a print and it works as expected.
(let [a (atom 0)
i (take-while (fn[x] (swap! a inc)
(< x 100)) [1 2 3 4 5])]
(println i)
[@a i]) ;; <== [5 (1 2 3 4 5)]
But, I still cant come up with a theory of what exactly i
The problem is that take-while is lazy, so it does not actually perform the
"taking" operation until the lazy-seq it returns is realized, e.g. by being
printed. So when your code binds the (take-while ...) expression to "i",
the anonymous function you provided is not yet being invoked, and thus
Hi,
I am a clojure newbie. I was working through some examples when I
discovered some behavior that I cant understand.
swap! behavior changes with the context it is used in.
If I put it in a 'take-while', swap! doesnt work :
(let [a (atom 0)
i (take-while (fn[x] (swap! a inc) (swank.core/
10 matches
Mail list logo