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% --
|
|---|
| 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 |