Proposal: add 'findLess' and variants to containers

Henning Thielemann lemming at
Sat Feb 18 21:18:55 CET 2012

On Sat, 18 Feb 2012, Twan van Laarhoven wrote:

> On 2012-02-18 00:51, Johan Tibell wrote:
>> Lets settle on the names. I
>> currently dislike that we have 'lookup' and 'findDefault' (which is
>> lookup with a default value.) We should agree on a principle for when
>> we use the two words.
> With regards to 'lookup' vs 'find': the current convention seems to be that 
> lookup* returns 'Maybe a', while find* returns 'a'. Compare for example 
> 'lookupIndex' and 'findIndex'.
>> Are there any good use cases for findLessEqual/findGreaterEqual,
>> instead of calling lookup and if it fails, call predecessor/successor?

These findLessEqual/findGreaterEqual remind me on the search for a string 
with the maximum common prefix. That is, if I have a (set :: Set String) 
and I want to find the member of 'set', that has the longest common prefix 
with a string 'str', then I know that either (findLessEqual str set) or 
(findGreaterEqual str set) is the wanted string.

More information about the Libraries mailing list