Jonathan Lang wrote:
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...
I certainly wouldn't have a problem with that. Of course, you could also easily implement those semantics on top of disjunctions:
class Set is Disjunction {
multi sub set is export(:MANDATORY) (Junction $j) { return Set.new(values=>$j.values) } multi sub set is export(:MANDATORY) ([EMAIL PROTECTED]) { return Set.new(values=>@_) }
multi sub infix:<!> (Set $a, Set $b) { set( $a | $b ) } multi sub infix:<&> (Set $a, Set $b) { set( $a & $b ) } multi sub infix:<-> (Set $a, Set $b) { set( $a & none($b) ) }
multi sub prefix:<-> (Set $a) { set( none($b) ) }
multi sub infix:«<=» (Set $a, Set $b) { true all($a.values) ~~ $b } multi sub infix:«>=» (Set $a, Set $b) { true $a ~~ all($b.values) } }
Damian