Created
January 5, 2012 08:01
-
-
Save sekia/1564198 to your computer and use it in GitHub Desktop.
mapBetween (ref. http://blog.livedoor.jp/dankogai/archives/51763038.html) in Perl 6
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
use v6; | |
sub mapBetween(@list, &fn) { | |
sub infix:<op>($a, $b) { &fn($a, $b) }; | |
@list <<op<< @list[1..*]; | |
} | |
say mapBetween([1..5], &[+]); # 3 5 7 9 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment