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