Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re: Abusing Map

by LanX (Sage)
on May 17, 2018 at 03:39 UTC ( #1214704=note: print w/replies, xml ) Need Help??

in reply to Abusing Map

I'm surprised nobody mentioned reduce yet.

Have a look a List::Util and/or List::MoreUtils


Sorry reduce is wrong (it returns a scalar) but close ...


we had similar discussions before, but I was only able to find "reduce like iterators" yet

Too tired to look further.

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)
Wikisyntax for the Monastery

Replies are listed 'Best First'.
Re^2: Abusing Map
by BrowserUk (Pope) on May 17, 2018 at 03:45 UTC
    I'm surprised nobody mentioned reduce yet.

    Because that doesn't work to produce the results the op wants.

    So mentioning it would be silly.

    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority". The enemy of (IT) success is complexity.
    In the absence of evidence, opinion is indistinguishable from prejudice. Suck that fhit
Re^2: Abusing Map
by ikegami (Pope) on May 18, 2018 at 08:07 UTC
    use List::MoreUtils qw( zip6 ); my @b = map { $_->[0] - $_->[1] } zip6 @{[ @a[0..$#a-1] ]}, @{[ @a[1..$#a] ]};


Re^2: Abusing Map
by Anonymous Monk on May 17, 2018 at 14:36 UTC

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1214704]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2021-09-22 18:12 GMT
Find Nodes?
    Voting Booth?

    No recent polls found