1.3.0 permalink Arrow_down_16x16
  • (or)
  • (or x)
  • (or x & next)
Evaluates exprs one at a time, from left to right. If a form
returns a logical true value, or returns that value and doesn't
evaluate any of the other expressions, otherwise it returns the
value of the last expression. (or) returns nil.

2 Examples top

  • user> (or true false false)
    true
    
    user> (or true true true)
    true
    
    user> (or false false false)
    false
    
    user> (or nil nil)
    nil
    
    user> (or false nil)
    nil
    
    user> (or true nil)
    true
    
    ;; or doesn't evaluate if the first value is true
    user> (or true (println "foo"))
    true
    
    ;; order matters
    user> (or (println "foo") true)
    foo
    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

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:789 top

(defmacro or
  "Evaluates exprs one at a time, from left to right. If a form
  returns a logical true value, or returns that value and doesn't
  evaluate any of the other expressions, otherwise it returns the
  value of the last expression. (or) returns nil."
  {:added "1.0"}
  ([] nil)
  ([x] x)
  ([x & next]
      `(let [or# ~x]
         (if or# or# (or ~@next)))))
Vars in clojure.core/or:
Used in 0 other vars

Comments top

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