Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^6: Abusing Map (Corrected second code block)

by BrowserUk (Patriarch)
on May 18, 2018 at 15:38 UTC ( [id://1214859]=note: print w/replies, xml ) Need Help??


in reply to Re^5: Abusing Map (Corrected second code block)
in thread Abusing Map

It does look to be the most efficient as you suspected.

The really fastest version -- which is only applicable if you no longer need the original array and can modify it in place, which is often the case in my work -- is:

my $i = 0; $x[ $i ] -= $x[ ++$i ] while $i < $#x; --$#x;

But the saving comes from not allocating more memory; and all the algorithms would benefit from that.


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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (6)
As of 2024-04-23 19:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found