macro | since v0.0-927 | clojure.core/and | Edit |
(and)
(and x)
(and x & next)
Evaluates arguments one at a time from left to right. If an argument returns
logical false (nil or false), and
returns that value and doesn't evaluate any
of the other arguments, otherwise it returns the value of the last argument.
(and)
returns true.
(and)
;;=> true
(and false)
;;=> false
(and true)
;;=> true
(and true true)
;;=> true
(and true false)
;;=> false
(and false false)
;;=> false
nil
and false
are the only falsy values and everything else is truthy:
(and "foo" "bar")
;;=> "bar"
(and "foo" nil)
;;=> nil
(and "foo" false)
;;=> false
(and nil "foo")
;;=> nil
(and false "foo")
;;=> false
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.
(core/defmacro and
([] true)
([x] x)
([x & next]
`(let [and# ~x]
(if and# (and ~@next) and#))))