In Sets, bags, and mixes§
See primary documentation in context for infix (-), infix ∖
Returns the set difference of all its arguments. More information, Wikipedia definition.
In Operators§
See primary documentation in context for infix (-), infix ∖
multi infix:<(-)>(**@p)
Returns the set difference of all its arguments. This creates a new Set
that contains all the elements the first argument has but the rest of the arguments don't, i.e., of all the elements of the first argument, minus the elements from the other arguments. But only if none of the arguments are a Bag
, BagHash
, Mix
or MixHash
.
say <a a b c a d> (-) <a a b c c>; # OUTPUT: «Set(d)» say <a b c d e> (-) <a b c> (-) <a b d>; # OUTPUT: «Set(e)»
If any of the arguments are Baggy
or Mixy
, the result is a new Bag
(or Mix
) containing all the elements remaining after the first argument with its weight subtracted by the weight of that element in each of the other arguments.
say <a a b c a d> (-) bag(<a b c c>); # OUTPUT: «Bag(a(2) d)» say <a a b c a d> ∖ mix(<a b c c>); # OUTPUT: «Mix(a(2) c(-1) d)»