Created
July 21, 2015 17:31
-
-
Save perlpilot/d1bda29d0928a4133a1e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- c/src/core/Any.pm | |
+++ w/src/core/Any.pm | |
@@ -256,7 +256,21 @@ my class Any { # declared in BOOTSTRAP | |
self.map({ next unless .match($test); $_ }); | |
} | |
multi method grep(Callable:D $test) is rw { | |
- self.map({ next unless $test($_); $_ }); | |
+ if ($test.count == 1) { | |
+ self.map({next unless $test($_); $_}); | |
+ } else { | |
+ my role CheatArity[$a,$c] { | |
+ has $.arity = $a; | |
+ has $.count = $c; | |
+ } | |
+ | |
+ my &tester = -> |c { | |
+ next unless $test(|c); | |
+ c.list | |
+ } but CheatArity[$test.arity, $test.count]; | |
+ | |
+ self.map(&tester); | |
+ } | |
} | |
multi method grep(Mu $test) is rw { | |
self.map({ next unless $_ ~~ $test; $_ }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment