Skip to content

Instantly share code, notes, and snippets.

@VienosNotes
Created January 5, 2012 09:01
Show Gist options
  • Save VienosNotes/1564339 to your computer and use it in GitHub Desktop.
Save VienosNotes/1564339 to your computer and use it in GitHub Desktop.
mapBetween
use v6;
sub mapBetween ($op, *@list) {
(@list Z @list[1..*]).map({ $op($^a,$^b) });
}
my @list = 1,2,3,4,5;
say mapBetween(&infix:<+>, @list);
say mapBetween(&infix:<+>, 1,2,3,4,5);
# 3 5 7 9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment