Saturday, December 31, 2016

set, match, meta operator

The common set operations; difference, join/intersect and union; may all be efficiently implemented on top of a meta operator that I've come to call 'match'. It does what it says: finds the next matching element, given two sets. The following examples are from libc4life's binary sets, but the idea is universally applicable.

the match operator

set operations

Once match is given, the actual operations read like poetry. For brevity, only join/intersect is included here; remaining operations vary only in the way they deal with matches/gaps.

Besides simplifying the implementation, exposing the underlying mechanism like this also gives user code a second chance for optimized access when provided operations don't fit the problem.

peace, out