Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: (golf) Interlaced Strings

by jmcnamara (Monsignor)
on May 02, 2001 at 13:42 UTC ( [id://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.
--

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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://77272]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (6)
As of 2024-03-28 16:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found