> Hello everybody,
>  The evaluation of
> (when-first [[x y z] [1 2 3 4 5]] (+ x y z))
> is returning
> nil
> I was expecting it to return 6 ..
> am I missing something ?

when-first is a macro which will, in the above example get expanded to -

(when (seq [1 2 3 4 5])
  (let [[x y z] (first [1 2 3 4 5])]
    (+ x y z)))

You can probably see where the problem is... when-first takes the
first item out of the collection that you pass it and tries to bind
it. So in this case, it's trying to bind 1 to [x y z] which is wrong.

May be you want [[1 2 3 4 5]] instead, but I don't know if that
satisfies your requirement.

Regards,
BG

-- 
Baishampayan Ghose
b.ghose at gmail.com

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to