1.3.0 permalink Arrow_down_16x16

rational?

clojure.core

  • (rational? n)
Returns true if n is a rational number

1 Example top

  • user=> (rational? 1)
    true
    user=> (rational? 1.0)
    false
    user=> (class 1.0)
    java.lang.Double
    
    ;; Note that decimal? only returns true if n is a BigDecimal.
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:3205 top

(defn rational? 
  "Returns true if n is a rational number"
  {:added "1.0"
   :static true}
  [n]
  (or (integer? n) (ratio? n) (decimal? n)))
Vars in clojure.core/rational?:
Used in 0 other vars

Comments top

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