Raul Miller wrote:
...
> You have basically the right idea, here, but I would
> characterize it as 3;1;4 is not a valid representation of
> a set, but realset 3;1;4 is a set.
>
> To see why, consider how you would test whether 3;1;4
> is an element of a set of sets.
>
> Put differently:
>
> NB. A "set" is 0$<1 or a sorted list of unique boxes
...
Raul,
I think it would need to be
NB. A "set" is 0$<1 or a 'realsetted' list of unique boxes.
We could require the user to use realset to create "sets" in this sense.
Compare
N
++---+---+-----+
||+-+|+-+|+-+-+|
|||0|||1|||1|0||
||+-+|+-+|+-+-+|
++---+---+-----+
/:~ N
++---+---+-----+
||+-+|+-+|+-+-+|
|||0|||1|||1|0||
||+-+|+-+|+-+-+|
++---+---+-----+
realset N NB. realset sorts 1;0 at one level then its list at the next
++---+-----+---+
||+-+|+-+-+|+-+|
|||0|||0|1|||1||
||+-+|+-+-+|+-+|
++---+-----+---+
NB. User creating a "set":
]S =: realset (0$<1);(,<0);(,<1);<1;0
++---+-----+---+
||+-+|+-+-+|+-+|
|||0|||0|1|||1||
||+-+|+-+-+|+-+|
++---+-----+---+
N -: (0$<1);(,<0);(,<1);<1;0
1
S -: realset N
1
I hear a user complaining, "Mendoksai!" (Too much trouble, rudely expressed)
and, "I want to keep an order meaningful in my application!"
For him we can keep the simpler definition of "set" and search for places to
put
&realset in our code, for example,
iselementof
<@[ e. ]
becomes
in =: iselementof & realset
S
++---+-----+---+
||+-+|+-+-+|+-+|
|||0|||0|1|||1||
||+-+|+-+-+|+-+|
++---+-----+---+
(1;0) in S
1
N
++---+---+-----+
||+-+|+-+|+-+-+|
|||0|||1|||1|0||
||+-+|+-+|+-+-+|
++---+---+-----+
(0;1) in N
1
What do you think?
Kip
Raul Miller wrote:
> On Fri, Aug 14, 2009 at 8:13 AM, Kip Murray<[email protected]> wrote:
>> The idea of verb realset is that
>>
>> realset 3;1;4
>> +-+-+-+
>> |1|3|4|
>> +-+-+-+
> ...
>> The lesson seems to be that every verb that may need to compare sets to do
>> its
>> work needs &realset . --I say "seems", I wouldn't be surprised if Raul has
>> spotted a deeper problem I haven't noticed. If so, Raul, will you amplify
>> your
>> remark about equalset and the model's definition of "set"?
>
> You have basically the right idea, here, but I would
> characterize it as 3;1;4 is not a valid representation of
> a set, but realset 3;1;4 is a set.
>
> To see why, consider how you would test whether 3;1;4
> is an element of a set of sets.
>
> Put differently:
>
> NB. A "set" is 0$<1 or a sorted list of unique boxes
>
> (Note also that I left out "non-empty" because you do
> not have a list of boxes if you have no boxes -- if you
> did, you would not need to explicitly mention 0$<1).
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm