- or download this
use feature qw(say state);
...
my @partitions = map { state $c = 0; [$c, $c += $_] } @widths;
say '[', join(', ', @$_), ']' for @partitions;
- or download this
[0, 2]
[2, 8]
[8, 13]
[13, 20]
- or download this
[2, 2]
[8, 8]
[13, 13]
[20, 20]