X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FAutobox%2FArray.pm;h=ab28fbf7876ccce63704e2eb4f132964bbe61d0f;hb=0e4809110e25a83f84e51bd913ae9e233fb3ce63;hp=21ce08a17cbb760a4f9bd85f54f348baa465496a;hpb=2dcdd7d70c44b88f199af083cc1ee68c072b5a16;p=gitmo%2FMoose-Autobox.git diff --git a/lib/Moose/Autobox/Array.pm b/lib/Moose/Autobox/Array.pm index 21ce08a..ab28fbf 100644 --- a/lib/Moose/Autobox/Array.pm +++ b/lib/Moose/Autobox/Array.pm @@ -3,7 +3,7 @@ use Moose::Role 'with'; use Perl6::Junction; use Moose::Autobox; -our $VERSION = '0.09'; +our $VERSION = '0.10'; with 'Moose::Autobox::Ref', 'Moose::Autobox::List', @@ -126,9 +126,7 @@ sub each { sub each_key { my ($array, $sub) = @_; - for my $i (0 .. $#$array) { - $sub->($i); - } + $sub->($_) for (0 .. $#$array); } sub each_value { @@ -136,6 +134,17 @@ sub each_value { $sub->($_) for @$array; } +sub each_n { + my ($array, $n, $sub) = @_; + my $it = List::MoreUtils::natatime($n, @$array); + + while (my @vals = $it->()) { + $sub->(@vals); + } + + return; +} + # end indexed sub flatten { @@ -237,6 +246,8 @@ This is a role to describe operations on the Array type. =item B +=item B + =back =head2 Indexed implementation @@ -255,6 +266,12 @@ This is a role to describe operations on the Array type. =item B +=item B + +=item B + +=item B + =back =head2 List implementation