Liking cljdoc? Tell your friends :D

same.core

Main public API namespace.

Main public API namespace.
raw docstring

ish?clj/s

(ish? expected & actuals)

Compare one or more values to an expected value, returning true if they are the same-ish. The values can be numbers:

(let [two (Math/pow (Math/sqrt 2) 2)]
  [(== 2 two) (ish? 2 two)])

or data structures:

(ish? {:a 1 :b [1.99999999999999 3]}
      {:a 1.00000000000001 :b [2 3.0]})

you can also compare more than one value to the expected value:

(ish? 1 1.0 0.99999999999999 1.00000000000001 1)
Compare one or more values to an expected value, returning true if they are the same-ish.
The values can be numbers:
```klipse
(let [two (Math/pow (Math/sqrt 2) 2)]
  [(== 2 two) (ish? 2 two)])
```
or data structures:
```klipse
(ish? {:a 1 :b [1.99999999999999 3]}
      {:a 1.00000000000001 :b [2 3.0]})
```
you can also compare more than one value to the expected value:
```klipse
(ish? 1 1.0 0.99999999999999 1.00000000000001 1)
```
sourceraw docstring

not-zeroish?clj/s

(not-zeroish? val & {:keys [scale] :or {scale 1000.0}})

Compare a numeric value to zero, returning true if not close. Equivalent to (not (zeroish? ...)).

(not-zeroish? 3 :scale 1e6)
Compare a numeric value to zero, returning true if not close. Equivalent to `(not (zeroish? ...))`.
```klipse
(not-zeroish? 3 :scale 1e6)
```
sourceraw docstring

set-comparator!clj/s

(set-comparator! comparator)

Set the default comparator.

(set-comparator! (compare-ulp 2.0 100))
(ish? 0.1 (-> 2 Math/sqrt (Math/pow 2) (- 1.9)))
Set the default comparator.
```klipse
(set-comparator! (compare-ulp 2.0 100))
(ish? 0.1 (-> 2 Math/sqrt (Math/pow 2) (- 1.9)))
```
sourceraw docstring

with-comparatorclj/smacro

(with-comparator comparator & body)

Temporarily replace the default comparator.

(with-comparator (compare-ulp 100.0 1e9)
  (ish? 1.0 0.9999999))
(with-comparator ==
  (ish? 1.0 0.9999999999999))
Temporarily replace the default comparator.
```klipse
(with-comparator (compare-ulp 100.0 1e9)
  (ish? 1.0 0.9999999))
```
```klipse
(with-comparator ==
  (ish? 1.0 0.9999999999999))
```
sourceraw docstring

zeroish?clj/s

(zeroish? val & {:keys [scale] :or {scale 1000.0}})

Compare a numeric value to zero, returning true if close.

(zeroish? 0.0000000001
          :scale 1e6)
Compare a numeric value to zero, returning true if close.
```klipse
(zeroish? 0.0000000001
          :scale 1e6)
```
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close