At 8:13 PM +1200 9/26/06, Sam Vilain wrote:
Darren Duncan wrote:
 > Within a system that already has an underlying
 set-like type, the Junction in this case, a test
 for uniqueness is (pardon any spelling):

    all(@items).elements.size === @items.size

 The all() will strip any duplicates, so if the
 number of elements in all(@items) is the same as
 > @items, then @items has no duplicates.

Perhaps, but then Junctions might not assume elements have equality or
identity operations defined.

As I recall, every type in Perl 6 has an equality and identity operation defined because the Object superclass provides one. If nothing else, the type's equality and identity are the same as =:= and .WHERE.

To do that you need to require this (and
which identity operator would you like to use today?),

Junction and Set and Mapping keys and Hash keys etc would simply use .WHICH and/or === when determining equality. That's one of the big advantages in having such generic operators. Simple.

And don't bring up eqv or whatever, since keying should always be on immutable things.

 and that would
also have the side effect of making creating a junction an O(N^2) operation.

Not if the type uses a hash-like index internally; then creating a junction (or set) is more like O(N).

I think that the S06 definition needs re-wording.  It's more like a Bag
than a Set AIUI.

I don't know what part you are reading, but the list of types that I see says that a Junction is "Sets with additional behaviours".

-- Darren Duncan

Reply via email to