You're viewing version 1.2.0 of or. The latest stable version of Clojure Core is 1.3.0.
1.2.0 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:705 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: defmacro next apply concat let list seq vector
Used in 128 other vars (expand)
find-protocol-impl the-ns bit-or some derive sequence integer? isa? extends? float? get-proxy-class refer mod io! rational? type agent merge browse-url delete-file skip-whitespace repl-read write pprint source print-trace-element trim-newline inc-report-counter next make-map print-stack-trace seqable? -valAt source find-javadoc-url recursive-component? string error? buffer-bytes delete-file jar-file? delete-file browse-url write impl-get-log impl-enabled? *impl-name* impl-write! exact-integer-sqrt gcd lcm constraint? monad-transformer pprint-defn prefix-count ltrim pprint add-core-ns normal-box-muller global-singleton connection* inc-report-counter mapcat-chain url-decode url-encode wrap-file time-series-plot box-plot add-box-plot add-categories $ stacked-bar-chart bar-chart heat-map xy-plot pie-chart scatter-plot line-chart function-plot add-points histogram add-function add-lines stacked-area-chart area-chart add-histogram constrain background tint color emissive fill defproject resolve-task -main make-dependency help-for get-default-jar-name skip-file? make-exclusion parse-github-url get-default-uberjar-name resolve! report-tally string-or-regex? union xml-zip maybe-ns resolve-ns one-of? find-or-spawn-repl-thread debugger-condition-for-emacs local-non-functions deep-replace variable-desc-for-echo-area split-compound-prefix-match? delimited-compound-prefix-match-acronym? value-part get-pid log-event ssh-sftp-cmd session default-session sftp create-ssh-agent new-object-tester s-seq changed-path

Comments top

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