Please consider an array such as :
arrayAll = [1,2,3,4,5,6,7,8,9]
Is there a package that enable to do partitioning to obtain :
arrayALLPartionned = [[1,2,3],[4,5,6],[7,8,9]]
I can see how to do this with a for loop but would appreciate a "pre-made" function if existing.
I think you will have to use a for loop, don't know of any inbuilt functions...
Try this function:
function splitarray(input, spacing)
{
var output = [];
for (var i = 0; i < input.length; i += spacing)
{
output[output.length] = input.slice(i, i + spacing);
}
return output;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With