Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # grep
- (1, 2, 3, 4, 5).grep({ $_ mod 2 != 0 }) ~~ (1, 3, 5) or die "Wrong list";
- # map
- (1, 2, 3, 4, 5).map({ $_ ** 2 }) ~~ (1, 4, 9, 16, 25) or die "Wrong list";
- # reduce
- (1, 2, 3, 4, 5).reduce({ $^a + $^b }) == 15 or die "Wrong value";
- # sort
- (4, 2, 5, 1, 3).sort({ $^b <=> $^a }) ~~ (5, 4, 3, 2, 1) or die "Wrong value";
- # zip
- zip((1, 2, 3), ("a", "b", "c")) ~~ ((1, "a"), (2, "b"), (3, "c")) or die "Wrong list";
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement