Set consolidation: Difference between revisions
Content added Content deleted
m (→{{header|J}}) |
|||
Line 1,039: | Line 1,039: | ||
<lang J>consolidate=:4 :0/ |
<lang J>consolidate=:4 :0/ |
||
b=. y 1&e.@e.&> x |
b=. y 1&e.@e.&> x |
||
(~.;x,b#y);(-.b)#y |
|||
)</lang> |
)</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: |
Examples: |