Set consolidation: Difference between revisions

m
Line 1,039:
<lang J>consolidate=:4 :0/
b=. y 1&e.@e.&> x
(1,-.b)#(~.;x,b#y);(-.b)#y
)</lang>
 
In other words, fold each set into a growing list of consolidated sets. When there's any overlap between the newly considered set and any of the list of previously considered sets, merge the unique values from all of those into a single set (any remaining sets remain as-is).
 
Examples:
6,962

edits