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