XP is just a number | |
PerlMonks |
Re^4: Merge 2 strings like a zip [benchmark]by roboticus (Chancellor) |
on Jul 09, 2015 at 22:06 UTC ( [id://1134047]=note: print w/replies, xml ) | Need Help?? |
When I saw your original version, I did basically the same thing (swap strings to make the shorter one last). The only problem is that it flips the order of the alternating characters--I expect the first argument to provide the first character, the second argument to provide the second, etc. I tried a couple quick hacks on yours (and kcotts) version to make it work the way I wanted, but when I didn't get it quickly, I punted. My quick hacks caused the strings to truncate when I was munging with substr on the left because it seems that I can't count properly today--I got bit several times by fencepost errors. For example, one of my attempts was to use zipC and change the starting value of $n based on which string was shorter, but had no luck--nor patience. You can see what I mean if you fix line 25:
...roboticus When your only tool is a hammer, all problems look like your thumb.
In Section
Seekers of Perl Wisdom
|
|