neversaint has asked for the wisdom of the Perl Monks concerning the following question:
Dear Masters,
I have arrays of which the sizes are always multiple of 3, e.g:
I have arrays of which the sizes are always multiple of 3, e.g:
Now what I want to do is to sum the elements in consecutive group of three, returning:my @arr = (0,0,1, 3,2,0, 1,1,1);
Is there a way to achieve that efficiently?my @output = (1, 5, 3);
---
neversaint and everlastingly indebted.......
neversaint and everlastingly indebted.......
Back to
Seekers of Perl Wisdom