requires 'Moose' => '0.42';
requires 'Perl6::Junction' => '1.40000';
-test_requires 'Test::More' => '0.62';
+test_requires 'Test::More' => '0.89';
test_requires 'Test::Exception' => '0.21';
auto_manifest;
$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 {
=item B<flatten_deep ($depth)>
+=item B<each_n ($n, $callback)>
+
=back
=head2 Indexed implementation
--- /dev/null
+use strict;
+use warnings;
+use Test::More;
+
+use Moose::Autobox;
+
+{
+ my @array = ('a' .. 'z');
+
+ my $aref = [ @array ];
+
+ {
+ my @vals;
+ @array->each_n(2, sub { push @vals, [@_] });
+ is(scalar @vals, 13);
+ is(scalar @$_, 2) for @vals;
+ is_deeply(@vals->map(sub { @{ $_ } }), [@array]);
+ }
+
+ {
+ my @vals;
+ $aref->each_n(2, sub { push @vals, [@_] });
+ is(scalar @vals, 13);
+ is(scalar @$_, 2) for @vals;
+ is_deeply(@vals->map(sub { @{ $_ } }), $aref);
+ }
+}
+
+done_testing;