1.3.0 permalink Arrow_down_16x16

even?

clojure.core

  • (even? n)
Returns true if n is even, throws an exception if n is not an integer

2 Examples top

  • user=> (even? 2)
    true
    
    user=> (even? 1)
    false
  • user=> (filter even? (range 10))
    (0 2 4 6 8)
Log in to add / edit an example.

See Also top

  • 0
    clojure.core/odd?

    Returns true if n is odd, throws an exception if n is not an integer

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:1315 top

(defn even?
  "Returns true if n is even, throws an exception if n is not an integer"
  {:added "1.0"
   :static true}
   [n] (if (integer? n)
        (zero? (bit-and (clojure.lang.RT/uncheckedLongCast n) 1))
        (throw (IllegalArgumentException. (str "Argument must be an integer: " n)))))
Vars in clojure.core/even?:
Used in 0 other vars

Comments top

No comments for even?. Log in to add a comment.