Evaluates exprs one at a time, from left to right. If a form
returns logical false (nil or false), and returns that value and
doesn't evaluate any of the other expressions, otherwise it returns
the value of the last expr. (and) returns true.
user=>(andtruetrue)trueuser=>(andtruefalse)falseuser=>(andfalsefalse)falseuser=>(and'()'())()user=>(and'[]'[])[]user=>(and01); Note that this is *not* bitwise 'and'1user=>(and10)0
; Note that, and does not evaluate if the first value is falseuser=>(andfalsenil)falseuser=>(andnilfalse)niluser=>(andfalse(println"foo"))falseuser=>(and(println"foo")false)fooniluser=>(andnilnil)nil
; From the Clojure 1.9 source code.(defnqualified-keyword?"Return true if x is a keyword with a namespace"[x](and(keyword?x)(namespacex)true)); Note how the return value of and is value of the last expression.user=>(qualified-keyword?:hi/there)true; If we instead define the function as:(defnqualified-keyword?[x](and(keyword?x)(namespacex))); we get the namespace as return value:user=>(qualified-keyword?:hi/there)"hi"
Note add is a macro, so you cannot apply it. For example, there is a vector of some Boolean values [true true false true], which you want to test to see if they are all true. The code below will not work: