in reply to Re^2: stack array to array of arrays
in thread stack array to array of arrays
I don't like it, IMHO it's
you might get used to it, but the next one to maintain your code wont be "pleased".
> It does often work for me though.
Look! If you need it often, so why don't you just use your custom routine?
Just compare the overhead to document this hack with just encapsulating all the infos in a sub!
Or use something from List::MoreUtils ?
DB<117> use List::MoreUtils qw/part/; DB<118> my $i; part {$i++ %3} a..h => (["a", "d", "g"], ["b", "e", "h"], ["c", "f"]) DB<119> use feature 'state'; part {state $i++ %3} a..h => (["a", "d", "g"], ["b", "e", "h"], ["c", "f"])
oops sorry, this transposed the matrix, corrected code:
DB<139> use feature "state"; part {state $i++/3} a..h => (["a", "b", "c"], ["d", "e", "f"], ["g", "h"])
Cheers Rolf
( addicted to the Perl Programming Language)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: stack array to array of arrays
by spandox (Novice) on Oct 17, 2013 at 17:43 UTC | |
by LanX (Saint) on Oct 17, 2013 at 17:57 UTC |