SRFI 223 bisect-left and bisect-right descriptions Sudarshan S Chawathe (19 Mar 2021 20:24 UTC)
Re: SRFI 223 bisect-left and bisect-right descriptions Daphne Preston-Kendal (20 Mar 2021 09:45 UTC)

Re: SRFI 223 bisect-left and bisect-right descriptions Daphne Preston-Kendal 20 Mar 2021 09:45 UTC

On 19 Mar 2021, at 21:24, Sudarshan S Chawathe <xxxxxx@eip10.org> wrote:

> Perhaps the following is too pedantic, but my intentions are wholly
> practical. I was hoping to create a "clean room" implementation of the
> SRFI using only the specification (not the code) as a guide and found
> myself confused.
>
> In the description of bisect-left, my assumption (could well be
> mistaken) is that the second sentence (starting with "In other words,")
> is meant to restate, not augment what is specified by the first.
> However, I don't see how the second sentence follows from the first.  I
> think a "leftmost" needs to be added to the first sentence (or some
> other fix made).  As it stands now, wouldn't always returning hi (among
> other options) satisfy the first sentence but not the second?

Yes, there’s an error in the spec there. bisect-left should, as you say,
return the *leftmost* index into a which satisfies the rule given in the
spec, and bisect-right one more than the rightmost index satisfying its
respective rule.

The language across the spec will be tightened up in general for the
third draft, but I think the API is basically done unless someone
convinces me to switch to SRFI 128 comparators (of which more in the
other thread).

> Regards, and wishing all a happy equinox,
>
> -chaw

Daphne