I've thought about this, and it's a lot more complicated than I indicated.
- item arrays, as you used in your example, are arrays, not maps. Thus, they CAN have duplicates:
> ashq foreach it in $items[snorkel, disco ball, snorkel ] print( it )
snorkel
disco ball
snorkel
So, we'd have to convert the arrays into sets, perform the operation (intersection, union, set_difference), and turn the result back into an array.
- maps cannot have duplicate elements, but they have both a key and a value. We can do (intersection, union, set_difference) on the keyset - but which value gets stored in the resulting map? If I have two maps that map int to int, one has 2->3, the other has 2->4, what IS the (intersection, union, set_difference)? The intersection is probably empty, and the union and set_difference probably includes BOTH mappings - which is not possible with a map.
It's still an interesting problem, but it's not straightforward - and there's a fair amount of specification, needed, to define what is the correct and useful syntax and behavior. Perhaps it only would work on arrays - which is exactly what you were asking about, anyway.
