Thanks for your replies Marshal & Jim.
I had not understood the 'laziness' concept correctly and was expecting it
to behave differently.
I thought that this post had somehow disappeared and I started another one
on the same topic. Sorry about that.
--Vinay
On Tuesday, 31 July 2012 18:17:00 U
"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 than 100.
>
> My first attempt didn't work. The counter returns 0
>
> (let [a (atom 0)
> i (take-while (fn[
If I understand correctly you don't need an atom to count the elements in a
seqall you need is 'count'
(let [s [1 2 3 4 5]
n (count s)]
(vector n s))
=> [5 [1 2 3 4 5]]
If you want to count only the first 100 you can first "take" as many as you
need and then count them...you can also
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
Thanks for looking this over! It's interesting how often I find myself
trying to use an Atom because I'm not coordinating changes multiple
things, just one, but the solution still requires using a Ref. I guess
it's wrong to think of what I'm doing as coordinating one value. I'm
really coordinating
Hi,
Am 21.03.2009 um 23:26 schrieb Mark Volkmann:
I'm looking for a suggestion on how I can get new-struct.
The other aspects aside, here an answer for this question.
(defn get-new-struct
[the-new-map]
(the-new-map (last (keys the-new-map
Or, to be sure,
(defn get-new-struct
[the
On Sat, Mar 21, 2009 at 6:12 PM, Laurent PETIT wrote:
> Hello Mark,
>
> 2 questions / suggestions :
>
> * couldn't step 2) be computed outside function b, and then my-data be
> replaced by new-struct ? This way, if you have several flavors of function
> b, you will not have to repeat the code in
Hello Mark,
2 questions / suggestions :
* couldn't step 2) be computed outside function b, and then my-data be
replaced by new-struct ? This way, if you have several flavors of function
b, you will not have to repeat the code in steps 1) and 3) in each of those
flavors of b ? And then the proble
I'm using an atom to hold a sorted-map whose keys are integer ids and
values are a particular kind of struct.
I have a function, call it "a", that adds an entry to this map.
It contains just this line:
(swap! my-atom b my-data)
"b" is a function that:
1) determines the next available id by getti