uniqStable

Andrea Fontana nospam at example.com
Tue Mar 19 01:16:19 PDT 2013


On Tuesday, 19 March 2013 at 02:09:06 UTC, timotheecour wrote:
> I forgot unittest:
>
> unittest{
> assert(uniqStable([1,3,1,0,2] ==[1, 3, 0, 2] ));
> }
> of course, it needs template on less, etc.

Stealing reply from Bearophile:
http://forum.dlang.org/post/rnsrrlmtguuayfxczsek@forum.dlang.org

He uses filter2 because filter doesn't cache results, but if you 
apply distinct() to a range where front() call is "stable" you 
can use filter.


More information about the Digitalmars-d-learn mailing list