in reply to a farewell to chop

The last time I used chop() was to solve a word puzzle. Find pairs of words that can be turned into one another by slicing in "half" and swapping the pieces... i.e.
vessel becomes selves: vessel => SLICE => 'ves' | 'sel' SWAP => 'sel' | 'ves' NEW => 'selves' loyal becomes alloy loyal => SLICE => 'loy' | 'al' SWAP => 'al' | 'loy' NEW => 'alloy'
The code that looped through the transformations looked something like:
$word = chop($word) . $word;
I can't say that I'll miss chop() but if it was up to me, I wouldn't remove it.

-Blake

Replies are listed 'Best First'.
Re: Re: a farewell to chop
by John M. Dlugosz (Monsignor) on Sep 12, 2002 at 14:57 UTC
    That also shows the similarity between chop on a string and pop on a list.

    Why not provide all the same commands (perhaps as members) that treat a string semantically as a list of characters? Have push, pop, shift, and unshift. substr is like splice.

    —John