Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
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
Replies are listed 'Best First'.
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 pondering the Monastery: (10)
As of 2015-07-07 22:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (93 votes), past polls