in reply to Re^4: Merge 2 strings like a zip [benchmark]
in thread Merge 2 strings like a zip

Try this:

sub zipD($$) { my( $a, $b ) = (my $o = length( $_[0] ) >= length( $_[1] ) ) ? @_ +[ 0, 1 ] : @_[ 1, 0 ]; substr( $a, $_*2+$o, 0, substr( $b, $_, 1 ) ) for 0 .. length( $b +) -1; return $a; }

Output:

C:\test>1133857.pl AaBbCcDdEeFGHIJaAbBcCdDeEFGHIJ AaBbCcDdEeFGHIJaAbBcCdDeEFGHIJ Rate Rr rR Dd dD Rr 85339/s -- -1% -40% -41% rR 86543/s 1% -- -39% -40% Dd 142186/s 67% 64% -- -2% dD 145076/s 70% 68% 2% --

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".
In the absence of evidence, opinion is indistinguishable from prejudice.
I'm with torvalds on this Agile (and TDD) debunked I told'em LLVM was the way to go. But did they listen!

Replies are listed 'Best First'.
Re^6: Merge 2 strings like a zip [benchmark]
by roboticus (Chancellor) on Jul 09, 2015 at 22:42 UTC

    BrowserUk:

    Beautiful!

    $ perl 1133959.pl AaBbCcDdEeFGHIJaAbBcCdDeEFGHIJ AaBbCcDdEeFGHIJaAbBcCdDeEFGHIJ Rate rR Rr Dd dD rR 334575/s -- -1% -53% -54% Rr 336364/s 1% -- -53% -53% Dd 713836/s 113% 112% -- -1% dD 720523/s 115% 114% 1% --

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.