2012 18:17:00 UTC+5:30, Marshall Vandegrift wrote:
>
> "Vinay D.E" writes:
>
> > I am a newbie and was doing some exercises when I ran across something
> that
> > I don't understand.
> > I am trying to count the number of elements in an array less th
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
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
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/
I am a newbie and was doing some exercises when I ran across something that
I don't understand.
I am trying to count the number of elements in an array less than 100.
My first attempt didn't work. The counter returns 0
(let [a (atom 0)
i (take-while (fn[x] (swap! a inc) (< x 100)) [1 2 3