1.2.0 permalink Arrow_down_16x16
  • (abs n)
(abs n) is the absolute value of n

1 Example top

  • user=> (abs -2)
    2
    
    user=> (abs 2)
    2
    
    user=> (abs 0)
    0
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/contrib/math.clj:122 top

(defn abs "(abs n) is the absolute value of n" [n]
  (cond
   (not (number? n)) (throw (IllegalArgumentException.
			     "abs requires a number"))
   (neg? n) (- n)
   :else n))
Vars in clojure.contrib.math/abs: - cond defn neg? not number?
Used in 0 other vars

Comments top

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