• (and)
  • (and x)
  • (and x & next)
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.

2 Examples top

  • user=> (and true true)
    true
    
    user=> (and true false)
    false
    
    user=> (and false false)
    false
    
    user=> (and '() '())
    ()
    
    user=> (and '[] '[])
    []
    
    user=> (and 0 1)  ; Note that this is *not* bitwise 'and'
    1
    
    user=> (and 1 0)
    0
    
    user=> (and (constantly true) (> 2 1))
    true
  • ;; See examples for "if" explaining Clojure's idea of logical true
    ;; and logical false.
Log in to add / edit an example.

See Also top

  • 0
    clojure.core/or

    Evaluates exprs one at a time, from left to right. If a form return

  • 0
    clojure.core/if

    Please see http://clojure.org/special_forms#if

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:777 top

(defmacro and
  "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."
  {:added "1.0"}
  ([] true)
  ([x] x)
  ([x & next]
   `(let [and# ~x]
      (if and# (and ~@next) and#))))
Vars in clojure.core/and:
Used in 0 other vars

Comments top

No comments for and. Log in to add a comment.