Brian, you implicitly asked why I want my set representations to be in a
standard order. Consider
]A =: set (set 0;1);2 NB. A is conventional { {0,1} , 2 }
┌─┬──────┬┐
│2│┌─┬─┬┐││
│ ││0│1││││
│ │└─┴─┴┘││
└─┴──────┴┘
]B =: set (set 1;0);2 NB. B is conventional { {1,0} , 2 }
┌─┬──────┬┐
│2│┌─┬─┬┐││
│ ││0│1││││
│ │└─┴─┴┘││
└─┴──────┴┘
A -: B
1
NB. C below is like B but the representation of {1,0} has not been sorted
]C =: a: ,~ 2;<(a: ,~ 1;0)
┌─┬──────┬┐
│2│┌─┬─┬┐││
│ ││1│0││││
│ │└─┴─┴┘││
└─┴──────┴┘
A -: C
0
There are two points here:
First, the names { {0,1} , 2 } and { {1,0) ,2 } refer to one and the same set
because the names {0,1} and {1,0} refer to one and the same set -- the
different
order in the latter names does not change the fact that {0,1} and {1,0} have
the
same members and so are the same set.
As I sort all sets, including sets that are elements of other sets, the names A
and B above refer to the same J object, and match -: finds A and B are the same.
Second, failing to sort would require writing a more lengthy test for equality
that would deal recursively with sets, sets which are elements, sets which are
elements of elements, and so on.
The point of 0 = A -: C above is that match did not find the representations of
{0,1} and {1,0} to be the same J object. The comparison involved sets which
were elements, and in general could involve sets which are elements of
elements,
sets which are elements of elements of elements, and so on.
Kip
On 10/11/2010 11:45 AM, Brian Schott wrote:
> Kip,
>
> As I think was discussed earlier in a thread you initiated on sets, I
> think someone pointed out that many folks would want their set
> elements to appear in the order they were supplied. Can you discuss
> this feature?
>
> (B=)
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm