Python's partition

Christopher Nicholson-Sauls ibisbasenji at gmail.com
Sat Jan 22 22:37:28 PST 2011


On 01/22/11 15:38, Andrei Alexandrescu wrote:
> On 1/22/11 3:33 PM, Christopher Nicholson-Sauls wrote:
>> On 01/22/11 11:44, Andrei Alexandrescu wrote:
>>> Looking through Python's string functions
>>> (http://docs.python.org/release/2.5.2/lib/string-methods.html) I noticed
>>> partition():
>>>
>>> partition(sep)
>>>      Split the string at the first occurrence of sep, and return a
>>> 3-tuple containing the part before the separator, the separator itself,
>>> and the part after the separator. If the separator is not found, return
>>> a 3-tuple containing the string itself, followed by two empty strings.
>>> New in version 2.5.
>>>
>>> Right now we find find and findSkip; partition would be a great
>>> complement, and can be implemented for all forward ranges.
>>>
>>> One question is naming - partition() is not good for us because
>>> std.algorithm.partition implements Hoare's in-place partition algorithm.
>>> How should we call the function?
>>>
>>>
>>> Andrei
>>
>> Bisect?
>>
>> -- Chris N-S
>>
> 
> Would be rather trisect, but that becomes a bit too cute.
> 
> Andrei

Yeah, you're right.  I hit on "bi-" because my mental image was like a
binary tree search.  Anywho, I actually kinda like "trisect," even if it
is cute.

-- Chris N-S


More information about the Digitalmars-d mailing list