Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sub filter($f, @arr) {
- gather {
- for @arr -> $e {
- take $e if $f($e);
- }
- }
- }
- my @even = filter({ $_ mod 2 == 0 }, 1..Inf)[0..4];
- @even ~~ (2, 4, 6, 8, 10) or die "Wrong array {@even}";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement