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=e43c8932ec49fa519489e3fde0d94fff98509ff3;hpb=c0ab09e353689f340e840f44b4158fc5a33790db;p=gitmo%2FMoose-Autobox.git diff --git a/lib/Moose/Autobox/Array.pm b/lib/Moose/Autobox/Array.pm index e43c893..ab28fbf 100644 --- a/lib/Moose/Autobox/Array.pm +++ b/lib/Moose/Autobox/Array.pm @@ -134,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 { @@ -235,6 +246,8 @@ This is a role to describe operations on the Array type. =item B +=item B + =back =head2 Indexed implementation