Re: Logical And

2009-02-11 Thread Onorio Catenacci
On Feb 10, 10:46 pm, Rayne wrote: > I literally asked this same question yesterday in #Clojure. The answer > is and > > user/ (doc and) > - > clojure.core/and > ([] [x] [x & rest]) > Macro >   Evaluates exprs one at a time, from left to right. If a form >   returns logical

Re: Logical And

2009-02-10 Thread Jeffrey Straszheim
Glad I could help. Enjoy coding. On Tue, Feb 10, 2009 at 10:43 PM, Onorio Catenacci wrote: > > On Feb 10, 10:14 pm, Jeffrey Straszheim > wrote: > > This one is easy: > > > >(and this that the-other-thing) > > > > and is short-circuting, e.g. it returns nil/false on reaching the first > > ni

Re: Logical And

2009-02-10 Thread Rayne
I literally asked this same question yesterday in #Clojure. The answer is and user/ (doc and) - clojure.core/and ([] [x] [x & rest]) Macro Evaluates exprs one at a time, from left to right. If a form returns logical false (nil or false), and returns that value and do

Re: Logical And

2009-02-10 Thread Onorio Catenacci
On Feb 10, 10:14 pm, Jeffrey Straszheim wrote: > This one is easy: > >    (and this that the-other-thing) > > and is short-circuting, e.g. it returns nil/false on reaching the first > nil/false element, or the value of the last element. > > I used it tonight like this: > >    (and x (inc x)) > >

Re: Logical And

2009-02-10 Thread Jeffrey Straszheim
Oh, and for your specific example, try: (and (= a something) (= b another-thing) (foo)) It will return false or (foo). On Tue, Feb 10, 2009 at 10:08 PM, Onorio Catenacci wrote: > > Hi all, > > Still working on learning Clojure. I think I know the answer to this > question (because I seem to

Re: Logical And

2009-02-10 Thread Jeffrey Straszheim
This one is easy: (and this that the-other-thing) and is short-circuting, e.g. it returns nil/false on reaching the first nil/false element, or the value of the last element. I used it tonight like this: (and x (inc x)) This returns x+1, unless x is nil, in which case it returns nil. Ma