Seq is already in use/consumed (nested gather / take )
The problem seems to be in your
take gather construct. It puts (still open)
Seqs inside your big outer
Seq. I "fixed" your code by substituting
take gather by
take my @x = gather and everything worked as you wish, I think.
There are three plausible scenarios.
In all of them,
take eager gather is the solution instead of
This leaves the outermost
You can leave it as is. This means if you bound the result of the
chunks call to a variable, and then did two iterating operations on it, you'd get the
Seq is already in use/consumed error.
Or you can deal with that problem. You have two options, depending on whether you prefer the
chunks operation to be eager or lazy. If you want it to be eager, then write the outer
eager gather. If you want it to be lazy, write it as