Email list hosting service & mailing list manager

there is no correct way to use list-sort! or list-stable-sort! William D Clinger (09 Mar 2016 12:31 UTC)
more corrections for SRFI 132 William D Clinger (10 Mar 2016 17:06 UTC)
Re: more corrections for SRFI 132 William D Clinger (10 Mar 2016 19:37 UTC)
Re: more corrections for SRFI 132 William D Clinger (10 Mar 2016 20:32 UTC)
benchmarking the SRFI 132 reference implementation William D Clinger (10 Mar 2016 23:20 UTC)
Re: more corrections for SRFI 132 William D Clinger (12 Mar 2016 03:07 UTC)
Re: more corrections for SRFI 132 Alex Shinn (12 Mar 2016 23:26 UTC)
Re: more corrections for SRFI 132 John Cowan (13 Mar 2016 22:02 UTC)

Re: more corrections for SRFI 132 William D Clinger 12 Mar 2016 03:06 UTC

In a previous message, I wrote:

> The specification of vector-select! is missing an ordering predicate.
> It is also said to run "in O(k) time", which is impossible because it
> must examine start-end elements, which is arbitrarily larger than k.

Now that I have implemented that procedure, I think it's a really
strange procedure for this SRFI to be specifying.  It would be more
useful to have a vector-select procedure such that

    (vector-select < v k [start [end]])

returns

    (vector-ref (vector-sort < v start end) (+ start k))

but probably runs faster because it doesn't have to sort the vector.
Larceny's implementation of SRFI 132 now includes an un-exported
implementation of vector-select that uses randomized quickselect,
and you could use Larceny's code in the reference implementation
for SRFI 132.

As a matter of fact, the best way I know to implement vector-select!
as specified in the current draft of the SRFI is to find the (k-1)th
element of the sorted subvector by calling vector-select as specified
above and then use that element as pivot to partition the subvector.

Will