in reply to Abusing Map
WRT this recent discussion thread: Forget map, if you want to take it up just that extra quantum energy level that allows you to achieve truly epic abuse, use grep:
c:\@Work\Perl\monks>perl -wMstrict -MData::Dump -le "my @ra = (1, 2, 3, 4); ;; my @rb; grep $rb[ $_-1 ] = $ra[ $_-1 ] + $ra[ $_ ], 1 .. $#ra; dd \@rb; " [3, 5, 7]
Update: Also works with
grep $rb[ $_ ] = $ra[ $_ ] + $ra[ $_+1 ], 0 .. $#ra-1;
with one fewer arithmetic operation per iteration!
Give a man a fish: <%-{-{-{-<
In Section
Seekers of Perl Wisdom