I understand now. Given a large list, you'd like to assign chunks of
the list to an array, easily, while looping. In other words, you're
looking for a way to abbreviate this:

my $chunk_size=10_000;
my @big='aaaa'..'mnop';
for ^...@big :by $chunk_size {
  my @chu...@big[$_..($_+$chunk_size,@big.end).min]
  ... # Do stuff with @chunk
}

I'm a perl6 novice so there probably is a more elegant way to write
the above already.

>From your original email, I like this idea-
for 'aaaa'..'mnop' -> *...@chunk[10_000] { ... } # @chunk is 10000 elems or less
though I think the syntax has to change a bit. I used the "*@" sigil
because "chunk" is slurpy, but only up to 10,000 items. Wrong on a
couple levels?

By the way, you shouldn't predeclare "@chunk" as you did in the
original example-
  my @a = <1 2 3 4>; my @b[2]; for @a ->@b {;}
the @b in the pointy block is a new declaration that shadows the
earlier "my @b[2]" declaration.

Reply via email to