$chunk_size = 10
@(1..100) | % { $c = @(); $i = 0 } { if ($i % $chunk_size -eq 0) { $c += ,@() }; $c[-1] += $_; $i++ }
$c
$chunk_size = 10 # Set desired chunk size
@(1..100) | % `
{ # Initialize loop variables
$c = @(); # Cumulating array of chunks
$i = 0; # Incrementing index
} {
if ($i % $chunk_size -eq 0) { # If the index is divisible by chunk size
$c += ,@() # Add another chunk to the accumulator
}
$c[-1] += $_; # Add current element to the last chunk
$i++ # Increment
}
$c