Email list hosting service & mailing list manager

Bisection functions should take a comparator argument Daniel Itaborai (16 Mar 2021 01:16 UTC)
Re: Bisection functions should take a comparator argument Daphne Preston-Kendal (16 Mar 2021 07:24 UTC)
Re: Bisection functions should take a comparator argument Marc Nieper-Wißkirchen (16 Mar 2021 07:52 UTC)
Re: Bisection functions should take a comparator argument Marc Nieper-Wißkirchen (16 Mar 2021 14:42 UTC)
Re: Bisection functions should take a comparator argument Daphne Preston-Kendal (20 Mar 2021 10:05 UTC)

Re: Bisection functions should take a comparator argument Daphne Preston-Kendal 16 Mar 2021 07:23 UTC

They do — the ‘less?’ argument. These procedures can also be used with comparators in the SRFI 128 sense quite easily: just pass the comparator-ordering-predicate of the comparator as the ‘less?’ argument.

In Draft 1 the ‘less?’ argument isn’t there on bytevector procedures as I thought it would be useless, but for the upcoming Draft 2 I’ve decided that bytevector binary search procedures are probably useless anyway (even if someone did have one sorted, a maximum of 256 values isn’t likely to yield large enough bytevectors for constant factors to mean that linear search wouldn’t win out in practice anyway), and replaced them with (a) convenience syntax for defining x-bisect-left and x-bisect-right procedures for a given x, and (b) an example in the prose showing how to use this syntax with x = bytevector. In practice, the larger SRFI 160 vector types (or indeed flexvectors as you mentioned in your previous mail) would be more useful targets, but I’d like this SRFI to be usable on R7RS small Schemes that possibly only define vectors and bytevectors and nothing else. (But I see now that I could use sublibraries, like (srfi 223 flexvector) or similar, to include that sort of thing. Hmm. Maybe.)

Thanks for your feedback so far, it’s been very helpful!

Daphne