%hash = ( A => 1, B => 2, C => 3);
$a = all(%hash.keys);
$a = $a & none('A');
Does $a.states now return ('B', 'C') ?
=Austin
> %hash = ( A => 1, B => 2, C => 3);
> $a = all(%hash.keys);
means: $a = 'A' & 'B' & 'C';
> $a = $a & none('A');
means: $a = 'A' & 'B' & 'C' & none('A')
> Does $a.states now return ('B', 'C') ?
No. C<.states> returns an empty list.
There is no non-junctive value that is simultaneously A and B and C, and
certainly no value that is both A and not A.
However:
$a = any(%hash.keys);
$a &= none('A');
would produce a junction for which C<.states> returns <<B C>>.
Damian
One day I'll figger this stuff out...
:-(
Thanks, Damian.
=Austin
If you're asking how to do set difference, I think the best way would
be to do:
%hash = ( A => 1, B => 2, C => 3);
$a = all(%hash.keys);
$a ^= 'A';
Although I can understand what you are trying to do, I'm not really
sure what that code segment would do.
Joseph F. Ryan
ryan...@osu.edu
Err. No.
Mathematical sets are inherently disjunctive.
So you need to base them on an C<any>.
That second attempt is equivalent to:
$a = ('A' & 'B' & 'C') ^ 'A'
which has the single C<.state>: 'A'
Damian
Ah, you're right. My mnemonic for remembering the junctional operators
threw me off; "& is like AND, | is like OR, ^ is like XOR..." However,
^ isn't really like XOR, its more like a pseduo-grep.
Thanks,
Joseph F. Ryan
ryan...@osu.edu
You are all switching and and or.
It would be far more intuitive, if the way to create a set were:
('a' | 'b' | 'c')
This would literally mean that this set was a ``superposition'' that
could contain
a OR b OR c.
Think of it this way;
let's say we encode the sets as bit strings:
i.e. 'a' -> b001
'b' -> b010
and c -> b100
(where b means binary)
If we OR these three togeather it is that the result will be
b111 which is precicely what we want.
I am quite aware that it would be completely impractical to actually
implement it this way, however, this is a usefull way to think about
it.
Further more, there would be no controversy over the meanings of & and
<xor operator> as and would select all items in both lists and <xor>
would take
all the items in one and only one list.
In fact, any operator that works on two booleans could have an analog
which works on sets. This would work by running the boolian operator
on the exeistances of the value in either of the two sets.
Sets could be ordinary
We could make a special character a bit like the hyperoperators in
arrays to do this,or we could use some other syntactic trick. It
doesn't really matter how this part is done.
If the character were a ~j sign
(Just for the sake of argument, I am sure there is a better choice)
Examples:
my $j1 = any(%hash.keys);
#to remove the value 'a':
$j1 ~j||= ~j!any('a');
#or
$j1 ~j||= none('a');
#to check whether 'a' exists:
print "yes" if $j1 ~j&& any('a');
-=+Marcello