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.

Make sense?

On Tue, Feb 10, 2009 at 10:08 PM, Onorio Catenacci <catena...@gmail.com>wrote:

>
> Hi all,
>
> Still working on learning Clojure.  I think I know the answer to this
> question (because I seem to have gotten it working) but I wanted to
> confirm that this is the right way to do this.
>
> In C++ I'd write something like this:
>
> if (a == something && b == anotherthing)
> {
>   foo();
> }
>
> Am I correct in thinking the Clojure equivalent is something like
> this:
>
> (if (= a something)
>   (if (= b anotherthing)
>      (foo)
>   )
> )
>
> Or is there another way to perform a logical and that I've missed?  As
> I said the latter form seems to work correctly--I was just wondering
> if there's some simpler way to perform the logical and.  And searching
> for "boolean" "logical" and "and" turned up too mainly results to be
> much use.
>
>
> --
> Onorio Catenacci III
> >
>

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