On Thu, Jan 03, 2013 at 11:14:30PM -0800, Evan Mezeske wrote:

Wouldn't it be more accurately named "if-and-let" if it supported that?  E.g.
(if (and x y z) ...).

I can see regular if-let being useful with more than one form, just
using the last value for the conditional.

   (if-let [a expr, b expr] ii ee)

could become

   (let [a expr, b expr] (if a ii ee))

Often, it is useful to have several intermediate results in a let:

   (if-let [subpart (complex-to-compute ...)
            part (other-expr subpart ... subpart)]
     ...)

David

On Thursday, January 3, 2013 10:24:57 PM UTC-8, Edward Tsech wrote:

   Hey guys,

   if-let and when-let macros support only 2 forms in binding vector:

   (if-let [x 1 y 2]
     ...)
   java.lang.IllegalArgumentExcepdtion: if-let requires exactly 2 forms
   in binding vector(NO_SOURCE_FILE:1)

   Why doesn't "if-let" support any even amount of binding forms as "let"
   does?

   e.g.
   (if-let [x 1 y 2 z 3]
     (+ x y z)
     0) ; => 6

   (if-let [x 1 y nil z 3]
     (+ x y z)
     0) ; => 0

   Thanks!

--
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

--
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