Permalink
Browse files

Add msubset and msuperset operators, clean up a glitch in infix:<(&)>.

  • Loading branch information...
1 parent 014fec3 commit 556574c804eb9a0b4d322e930cd12f4ad6a834aa @colomon colomon committed Jun 7, 2012
Showing with 9 additions and 1 deletion.
  1. +9 −1 lib/CORE.setting
View
@@ -2099,7 +2099,7 @@ only sub infix:<(|)>($a, $b) is equiv(&infix:<X>) { $a ∪ $b }
proto sub infix:<∩>($, $ --> Set) is equiv(&infix:<X>) {*}
multi sub infix:<∩>(Any $a, Any $b --> Set) { Set($a) Set($b) }
multi sub infix:<∩>(Set $a, Set $b --> Set) { Set.new: $a.keys.grep: -> $k { ?$b{$k} } }
-only sub infix:<(&)>($a, $b --> Set) is equiv(&infix:<X>) { $a $b }
+only sub infix:<(&)>($a, $b) is equiv(&infix:<X>) { $a $b }
proto sub infix:<(-)>($, $ --> Set) is equiv(&infix:<X>) {*}
multi sub infix:<(-)>(Any $a, Any $b --> Set) { Set($a) (-) Set($b) }
@@ -2255,6 +2255,14 @@ multi sub infix:<⊎>(Any $a, Any $b --> Bag) { bag($a) ⊎ bag($b) }
multi sub infix:<⊎>(Bag $a, Bag $b --> Bag) { bag((set($a) ∪ set($b)).map({ ; $_ => $a{$_} + $b{$_} })) }
only sub infix:<(+)>($a, $b --> Bag) is equiv(&infix:<X>) { $a ⊎ $b }
+proto sub infix:<≼>($, $ --> Bool) is equiv(&infix:<==>) {*}
+multi sub infix:<≼>(Any $a, Any $b --> Bool) { bag($a) ≼ bag($b) }
+multi sub infix:<≼>(Bag $a, Bag $b --> Bool) { so all $a.keys.map({ $a{$_} <= $b{$_} }) }
+
+proto sub infix:<≽>($, $ --> Bool) is equiv(&infix:<==>) {*}
+multi sub infix:<≽>(Any $a, Any $b --> Bool) { bag($a) ≽ bag($b) }
+multi sub infix:<≽>(Bag $a, Bag $b --> Bool) { so all $b.keys.map({ $b{$_} <= $a{$_} }) }
+
class KeyBag does Associative does Baggy {
has Int %!elems; # should be UInt

0 comments on commit 556574c

Please sign in to comment.