3. Comparison Functions
The comparison/ library provides additional equality and ordering operations.
Table of Contents
3.1. Comparison functions ↑
3.1.1. comparison/not= ↑
Function(comparison/not= value more*) → boolean
Returns the negation of the corresponding equality call. This means that not all
arguments are equal, rather than requiring every pair to differ. One argument
returns false; no arguments is an error. Equality retains its matching-kind
checks and stops comparing after the first unequal pair.
DUST
=(comparison/not= 1 2) (comparison/not= 1 1) (comparison/not= 1) (comparison/not= 1 2 x)
DUST Result
true false false true
3.1.2. comparison/identical? ↑
Function
Returns true if its operands refer to the same value, otherwise false.
Errors raised at the same place with the same tags and message may be the
same value.
DUST
→(comparison/identical? hello "hello")
Canonical DUST
=(comparison/identical? hello hello)
DUST Result
true
DUST
→(let [es (map (fn [i] (/ .i 0)) [1 2])] (comparison/identical? (first .es) (lists/second .es))) (let [es (map (fn [s] (int .s)) ["x" "y"])] (comparison/identical? (first .es) (lists/second .es))) (let [es (map (fn [v] (/ 1 .v)) [0 "a"])] (comparison/identical? (first .es) (lists/second .es))) (comparison/identical? (/ 1 0) (/ 2 0)) (let [es (map (fn [i] (/ .i 0)) [1 2])] (= (first .es) (lists/second .es))) (map (fn [i] (/ .i 0)) [1 2])
Canonical DUST
=(let [es (map (fn [i] (/ .i 0)) [1 2])] (comparison/identical? (first .es) (lists/second .es))) (let [es (map (fn [s] (int .s)) [x y])] (comparison/identical? (first .es) (lists/second .es))) (let [es (map (fn [v] (/ 1 .v)) [0 a])] (comparison/identical? (first .es) (lists/second .es))) (comparison/identical? (/ 1 0) (/ 2 0)) (let [es (map (fn [i] (/ .i 0)) [1 2])] (= (first .es) (lists/second .es))) (map (fn [i] (/ .i 0)) [1 2])
DUST Result
true true false false true [#err {<division integer zero> message "division by zero"} #err {<division integer zero> message "division by zero"}]
DUST
→(let [a {x 1} b {x 1} c .a] (comparison/identical? .a .b))
Canonical DUST
=(let [a {x 1} b {x 1} c .a] (comparison/identical? .a .b))
DUST Result
false
DUST
→(let [a {x 1} b {x 1} c .a] (comparison/identical? .a .c))
Canonical DUST
=(let [a {x 1} b {x 1} c .a] (comparison/identical? .a .c))
DUST Result
true
DUST
→(let [f (fn [x] .x) g .f h (fn [x] .x)] (comparison/identical? .f .g))
Canonical DUST
=(let [f (fn [x] .x) g .f h (fn [x] .x)] (comparison/identical? .f .g))
DUST Result
true
DUST
→(let [f (fn [x] .x) g .f h (fn [x] .x)] (comparison/identical? .f .h))
Canonical DUST
=(let [f (fn [x] .x) g .f h (fn [x] .x)] (comparison/identical? .f .h))
DUST Result
false