Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: (golf) Interlaced Strings

by jmcnamara (Monsignor)
on May 02, 2001 at 13:42 UTC ( #77272=note: print w/ replies, xml ) Need Help??


in reply to (golf) Interlaced Strings


Strange. Nobody used bitwise or. The following is 41 chars:

sub R1{ $_=sub{join"\0",split//,pop};"\0".&$_|&$_ }

This is 37 chars but would clobber a subroutine called "_":
sub R2{ sub _{join"\0",split//,pop}"\0".&_|&_ }

This is 33 chars but doesn't preserve case:
sub R3{ sub _{join$",split//,pop}$".&_|&_ }


John.
--


Comment on Re: (golf) Interlaced Strings
Select or Download Code
Re: Re: (golf) Interlaced Strings
by MeowChow (Vicar) on May 02, 2001 at 23:09 UTC
    Nice. You can save 2 chars on these by replacing:
    split//,pop
    with
    pop=~/./g # or just 1 char if you put in the 's' modifier
       MeowChow                                   
                   s aamecha.s a..a\u$&owag.print

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (8)
As of 2014-10-25 13:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (143 votes), past polls