Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Abusing Map

by LanX (Cardinal)
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

update

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

update

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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2020-11-25 00:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?