Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!
  • Clojure

Idiom #114 Test deep equality

Set boolean b to true if objects x and y contain the same values, recursively comparing all referenced elements in x and y.
Tell if the code correctly handles recursive types.

(def b (identical? x y))

for external entities, identical will check if references point to the same object
(def b (= x y))

for clojure entities, = will always use deep equality
b = deeplyEqual(x, y));

See the online demo for more information about the function deeplyEqual (20 LOC).

New implementation...
< >
programming-idioms.org