Union, intersection... for dicts

Hi,

Was wondering if anyone had written (or q had built-in) an implementation for set operations on dictionaries like:

q)a:ab!0 1;b:yz!8 9;c:by!4 5

q)UNION[a;c]

a| 0

b| 1 4

y| 5

q)0N!INTER[a;b]

(symbol$())!long$()

… or maybe ..

b| 

q) /DIFF/DROP …

i’d like functions in similar spirit to the way dyadic verbs work ,± that return a dict.  

i’m working on these functions, but i bet i’d learn a bit from seeing someone else’s code.

Thanks,

Jack.

if you ensure the values of your dictionaries are lists, then the standard ‘union’, ‘inter’ and ‘except’ will work:

q)a:ab!enlist each 0 1;b:yz!enlist each 8 9;c:by!enlist each 4 5
q)a union’ c
a| ,0
b| 1 4
y| ,5
q)a inter’ c
a|
b|
y|
q)a except’ c
a| ,0
b| ,1
y| `long$()