Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^2: printing every 2nd entry in a list backwards

by shmem (Chancellor)
on May 19, 2017 at 18:19 UTC ( #1190662=note: print w/replies, xml ) Need Help??


in reply to Re: printing every 2nd entry in a list backwards
in thread printing every 2nd entry in a list backwards

Here's a mapslice

mapslice => sub { my @x = @::list[ map {$_<<1} reverse 0..@::list>>1 ] + }

which you might want to add.

perl -le'print map{pack c,($-++?1:13)+ord}split//,ESEL'

Replies are listed 'Best First'.
Re^3: printing every 2nd entry in a list backwards
by tobyink (Abbot) on May 19, 2017 at 18:21 UTC

    Yeah, that's pretty fast.

    # pairmap - 4 wallclock secs ( 3.18 usr + 0.00 sys = 3.18 CPU) @ 17 +5.47/s (n=558) # grepbit - 3 wallclock secs ( 3.26 usr + 0.00 sys = 3.26 CPU) @ 11 +4.72/s (n=374) # mapslice - 3 wallclock secs ( 3.25 usr + 0.00 sys = 3.25 CPU) @ 1 +08.92/s (n=354) # mapidx - 3 wallclock secs ( 3.20 usr + 0.01 sys = 3.21 CPU) @ 76. +64/s (n=246) # mapmy - 3 wallclock secs ( 3.06 usr + 0.00 sys = 3.06 CPU) @ 73.8 +6/s (n=226) # grepmy - 3 wallclock secs ( 3.01 usr + 0.00 sys = 3.01 CPU) @ 69. +44/s (n=209) # grepstate - 3 wallclock secs ( 3.17 usr + 0.00 sys = 3.17 CPU) @ +34.07/s (n=108)

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1190662]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2017-10-23 12:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (279 votes). Check out past polls.

    Notices?