Re: more corrections for SRFI 132
John Cowan 13 Mar 2016 22:02 UTC
William D Clinger scripsit:
> 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.
I'm adding this to the SRFI as vector-select! and Alex's code as
vector-separate! I think it makes sense to have both, given that
if you only care about a single value, you can use vector-select!
in O(n) time, whereas if you care about the "top k" values (or
bottom k), you can use vector-separate! also in O(n) time.
--
John Cowan http://www.ccil.org/~cowan xxxxxx@ccil.org
The native charset of SMS messages supports English, French, mainland
Scandinavian languages, German, Italian, Spanish with no accents, and
GREEK SHOUTING. Everything else has to be Unicode, which means you get
only 70 16-bit characters in a text instead of 160 7-bit characters.