Do sorted ranges have any special properties?
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Tue Jul 27 06:49:54 PDT 2010
Philippe Sigaud wrote:
>
>
> On Tue, Jul 27, 2010 at 07:13, Andrei Alexandrescu
> <SeeWebsiteForEmail at erdani.org <mailto:SeeWebsiteForEmail at erdani.org>>
> wrote:
>
> Tomek Sowiński wrote:
>
> Andrei Alexandrescu wrote:
>
> median -> r[r.length / 2]
>
>
> Generalize to quantile.
> http://en.wikipedia.org/wiki/Quantile
>
>
> Makes sense.
>
> Andrei
>
>
>
> Ah, not as methods, but free functions taking sorted ranges:
>
>
> * fast merge (on n ranges in one go),
> * fast intersection, union, difference, symmetricDifference. But I see
> these already exist in std.algo for sets.
> * Also, maybe, some kind of takeUpTo(range, Max), that takes all values
> up to a certain value Max. As it's ordered, we know there is no more
> value less than Max. I don't if there is a mathematical name for that.
>
> It's just a specialized takeWhile!((ElementType!R v) { return
> v<Max;})(range);
>
> btw, takeWhile is a _very_ useful function to add to std.algorithm.
I definitely wanted to add that... in fact I vaguely thought I did!
Could you please make a bugzilla entry so it's not forgotten?
Thanks,
Andrei
More information about the Digitalmars-d
mailing list