Symmetric Difference for Data.Set and Data.IntSet?

Could this be implemented as a primitive? I know it can be made from union and difference, or doing toList on both of them, taking the symmetric difference, and using fromDistinctAscList on the result, but it'd probably be much faster if it could be done natively, like can be done with Data.Map.mergeWithKey. Alternatively, could we get a merge interface for Set and IntSet roughly matching Map and IntMap?

On 20/06/15 21:49, Zemyla wrote:
Alternatively, could we get a merge interface for Set and IntSet roughly matching Map and IntMap?
Could you expand on what you mean? I understand it as that having operations of (Int)Map for (Int)Set, why don't just use (Int)Map then?

I think he means
symmetricDifference a b = (a `union` b) `difference` (a `intersection` b)
Or equivalently
symmetricDifference a b = (a `difference` b) `union` (b `difference` a)
Basically the elements in one of the two sets but not both. He's claiming a
direct function would be faster than combining three.
Note that (a `difference` b \= b `difference` a) but (a
`symmetricDifference` b == b `symmetricDifference` a).
On Sun, Jun 21, 2015 at 3:15 PM, Ruben Astudillo
On 20/06/15 21:49, Zemyla wrote:
Alternatively, could we get a merge interface for Set and IntSet roughly matching Map and IntMap?
Could you expand on what you mean? I understand it as that having operations of (Int)Map for (Int)Set, why don't just use (Int)Map then? _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe

Zemyla wrote:
Could this be implemented as a primitive? I know it can be made from union and difference, or doing toList on both of them, taking the symmetric difference, and using fromDistinctAscList on the result, but it'd probably be much faster if it could be done natively, like can be done with Data.Map.mergeWithKey.
+1
Alternatively, could we get a merge interface for Set and IntSet roughly matching Map and IntMap? -- "Make it so they have to reboot after every typo." ― Scott Adams

On Sun, Jul 5, 2015 at 6:33 PM, Ben Franksen
Zemyla wrote:
Could this be implemented as a primitive? I know it can be made from union and difference, or doing toList on both of them, taking the symmetric difference, and using fromDistinctAscList on the result, but it'd probably be much faster if it could be done natively, like can be done with Data.Map.mergeWithKey.
+1
I'm also very +1. -- Live well, ~wren
participants (5)
-
Ben Franksen
-
Clinton Mead
-
Ruben Astudillo
-
wren romano
-
Zemyla