basilisp.data

Utility function for diffing arbitrary data structures.

All builtin Basilisp and Python data structures are supported by default. Support can be added to custom data types by extending protocol IDiffable.

protocolIDiffable
fn (diff* this other)

Diff other against this, returning a three element vector containing [items-in-a items-in-b items-in-both].

fn (diff a b)

Diff items a and b, returning a three element vector containing [items-in-a items-in-b items-in-both].

Items are diffed according to the following heuristics:

  • Mapping types (for both Basilisp maps and Python dicts) are compared by key and values and are sub-diffed where values differ for the same key. Python dicts will be coerced to Basilisp maps before diffing.

  • Sequential types (for Basilisp lists and vectors and Python lists and tuples) are compared by value at the corresponding index in the other collection. Values at each index are compared according to the rules in this list. Sequential types are always returned as vectors.

  • Sets (for both Basilisp and Python set types) are compared by their values, which are never sub-diffed. Python sets and frozensets will be coerced to Basilisp sets before diffing.

  • All other types are compared for equality as by basilisp.core/=.