Skip to content

Instantly share code, notes, and snippets.

@Mouq

Mouq/Minus.diff Secret

Created May 25, 2015 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mouq/e6ab6ff6acbfbc6dd032 to your computer and use it in GitHub Desktop.
Save Mouq/e6ab6ff6acbfbc6dd032 to your computer and use it in GitHub Desktop.
diff --git a/src/core/set_operators.pm b/src/core/set_operators.pm
index aaf654e..d3fa24e 100644
--- a/src/core/set_operators.pm
+++ b/src/core/set_operators.pm
@@ -123,13 +123,13 @@ only sub infix:<(-)>(**@p) {
}
$baghash.Bag(:view);
} else {
- my $sethash = nqp::istype(@p[0],SetHash)
- ?? SetHash.new(@p.shift.keys)
- !! @p.shift.SetHash;
- for @p.map(*.Set(:view)) -> $set {
- $set{$_} && $sethash.DELETE-KEY($_) for $sethash.keys;
- }
- $sethash.Set(:view);
+ my $start-set = @p.shift.Set(:view);
+ my $minus-set = @p == 1
+ ?? @p[0].Set(:view)
+ !! Set.new(eager @p.map(*.Set(:view).keys));
+ Set.new(eager $start-set.keys.grep: {
+ not $minus-set{$_}
+ });
}
}
# U+2216 SET MINUS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment