[Python-ideas] New explicit methods to trim strings

Jonathan Fine jfine2358 at gmail.com
Mon Mar 25 08:19:35 EDT 2019


More on negative strings. They are easier, if they only use one character.

Red Queen: What's one and one and one and one and one and one and one and
one and one and one and one and one and one?
Alice: I don't know. I lost count.
Red Queen: She can't do arithmetic.

3 --> 'aaa'
2 --> 'aa'
1 --> 'a'
0 --> ''
-1 -> -'a'
-2 -> -'aa'
-3 -> -'aaa'

Negative strings are easier if we can rearrange the order of the letters.
Like anagrams.

    >>> ''.join(sorted('forty five'))
    ' effiortvy'
    >>> ''.join(sorted('over fifty'))
    ' effiortvy'

Instead of counting (positively and negatively) just the letter 'a', we do
the whole alphabet.

By when order matters, we get an enormous free group, which Python
programmers by accident see.

I hope this helps.

-- 
Jonathan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20190325/d5f1b631/attachment.html>


More information about the Python-ideas mailing list