how to get top N distinct elements from range?
Andrea Fontana
nospam at example.com
Fri Mar 8 15:59:27 PST 2013
On Friday, 8 March 2013 at 23:51:48 UTC, bearophile wrote:
> Andrea Fontana:
>
>> Here the answer:
>>
>> auto r=iota(100).map!((x) => uniform(0,10))();
>> writeln(r.front," ", r.front, " ", r.front, " ", r.front);
>
> I think that's not the answer. I think the answer is a bug in
> filter().
>
> Bye,
> bearophile
My struct version never work if map doesn't cache. Every time I
call (inside popFront() too!) front() gives different values.
If i do array.distinct() it works fine: an array is filled with
random values and they will never changes again.
More information about the Digitalmars-d-learn
mailing list