Skip to content

clojure.data/diff

View this page on ClojureDocs

Type: function Added: Clojure 1.3 Examples: 5 Runnable: 0
([a b])

Recursively compares a and b, returning a tuple of [things-only-in-a things-only-in-b things-in-both]. Comparison rules:

  • For equal a and b, return [nil nil a].
  • Maps are subdiffed where keys match and values differ.
  • Sets are never subdiffed.
  • All sequential things are treated as associative collections by their indexes, with results returned as vectors.
  • Everything else (including strings!) is treated as an atom and compared for equality.

Examples

by joshrotenberg on . May have evaluation errors.
by vede1 on . May have evaluation errors.
by zootalures on . May have evaluation errors.
by Biserkov on . May have evaluation errors.
by marcoslimagon on . May have evaluation errors.

Note by Bost

See also https://github.com/lambdaisland/deep-diff2 "Deep diff Clojure data structures and pretty print the result"

Note by huahaiy

See https://github.com/juji-io/editscript "Editscript is a library designed to extract the differences between two Clojure/Clojurescript data structures as an 'editscript', which represents the minimal modification necessary to transform one to another"


Content from the matching ClojureDocs page, with authors credited on each contribution.