HaloO, Darren Duncan wrote:
I was not meaning to get into implementation issues so much as just to say that all bag values are a superset of all set values.
I agree with that. And I end up wanting a nice syntax to create a supertype. This is particularly needed if the Bag type shall be loadable as module whereas the Set is a base type. The problem is the same as one might want to supertype Num with Complex. OK, Complex is perhaps a base type, but the latest when it comes to supertyping quaternions onto Complex, a module is asked for. A FuzzySet would be another supertype of Set that will hardly be a core type. So, how do we do supertyping? Funny result is that with 'Set does Bag' and 'Seq does Bag' and Bag coming from a module, without loading it Set and Seq have not even an indirect relation. But then again 'Seq does Bag' is doubtful anyway because there are several Seq values for a single Bag. This collapsing of several Sequences into a single Bag does not establish a subset relation. Non the less picking a particular order for a Bag constitutes an interface subtype. The latter is the only reason why the issue came up in this thread. Note that the iteration interface would ideally be available from the Bag type. So we might want to make it a core type. What's @Larry's opinion on that?
Bag(1,2,2,2,3,3) symmetric_difference Bag(1,2,2,4,4); # Bag(2,3,3,4,4) or Bag(3,3,4,4) ?
This is just the union (1,2,2,2,3,3,4,4) minus the intersection (1,2,2): (2,3,3,4,4). And I still think that it is a good idea to name the set operations after their equivalent boolean connectives: (|) union (&) intersection (^) symmetric difference Well, and to make them Bag operations to start with. Regards, TSa. --