Rod Adams wrote:
> Now that I've gotten some feedback from my original message (on list and
> off), and have had some time to think about it some more, I've come to 
> some conclusions:
> 
>    Junctions are Sets.  (if not, they would make more sense if they
> were.)

As pointed out elsewhere, Junctions are special _types_ of sets, with
additional details associated with them.  

>    If we want Sets in Perl, we should have proper Sets.

I'll agree, depending on what you mean by "proper".  I'd be interested in
having some means to perform set operations in perl6: unions,
intersections, differences, membership checks, and subset/superset checks.
 Mind you, I _like_ Junctions, and I'd rather not toss them out in order
to make room for Sets.  I'd rather have both if possible.  

How many of the Set operators can be defined in terms of Junctions?  

# where $A and $B are sets of some sort, and $e is an element:
  union($A, $B)        =:= $A | $B;
  intersection($A, $B) =:= $A & $B;
  not($A)              =:= ????
  difference($A, $B)   =:= $A & not($B);
  $e is_element_of $A  =:= $e == $A; # only if $A is an "any" Junction.
  $A is_subset_of $B   =:= $A == $B; # only if $A is "all" and $B is "any"
  $A is_superset_of $B =:= $A == $B; # only if $A is "any" and $B is "all"

Using lists as the baseline, 

  union(@A, @B)        =:= any(@A) | any(@B);
  intersection(@A, @B) =:= any(@A) & any(@B);
  not(@A)              =:= none(@A);
  difference(@A, @B)   =:= any(@A) & none(@B);
  $e is_element_of @A  =:= $e == any(@A);
  @A is_subset_of @B   =:= all(@A) == any(@B);
  @A is_superset_of @B =:= any(@A) == all(@B);

It occurs to me that a big stumbling block is that there's no intuitive
way that I know of to negate junctions - and, FWIW, the only junction
types that have "opposite" junction types defined are "any" and "none":
"none(@A)" is "not any(@A)", where "not" is defined in terms of sets
rather than booleans.  There's no concise version of "not all(@A)" or "not
one(@A)", nor should there be.  

It would also be nice if there was a way to force an existing junction to
act as a different type of junction; with that capability, you could say
something like:

# $A and $B are "any" junctions, and $e is an element:
  union($A, $B)        =:= ($A | $B); 
  intersection($A, $B) =:= ($A & $B); 
  not($A)              =:= $A.asNone; 
  difference($A, $B)   =:= ($A & $B.asNone); 
  $e is_element_of $A  =:= ($e == $A); 
  $A contains $e       =:= ($A == $e); 
  $A is_subset_of $B   =:= ($A.asAll == $B); 
  $A is_superset_of $B =:= ($A == $B.asAll); 

Sloppy, but it does the job.  Is there a cleaner way to do this?  

Maybe "set" should be an operator akin to "any", "all", "one", and "none",
at least in terms of "&" and "|".  That is, if junctions are special cases
of sets, why not allow for the creation of generic sets in much the same
way?  Then you could have:

# $A and $B are sets,
  union($A, $B)        =:= ($A | $B); 
  intersection($A, $B) =:= ($A & $B); 
  not($A)              =:= (! $A); 
  difference($A, $B)   =:= ($A - $B); 
  $e is_element_of $A  =:= ($e ~~ $A);
  $A is_subset_of $B   =:= ($A <= $B); 
  $A is_superset_of $B =:= ($A >= $B); 

...and so on.  Hmm...

=====
Jonathan "Dataweaver" Lang


                
__________________________________ 
Do you Yahoo!? 
All your favorites on one personal page – Try My Yahoo!
http://my.yahoo.com 

Reply via email to