Re: Minimum value in a range

2011-08-05 Thread bearophile
Kai Meyer: > minCount is, or the usage of minCount in his particular problem? Your usage seems OK. What I meant is that I don't like the design of min/max/minCount. I have expressed my ideas here: http://d.puremagic.com/issues/show_bug.cgi?id=4705 I'd like to know what Andrei thinks about it. Th

Re: Minimum value in a range

2011-08-05 Thread Kai Meyer
On 08/04/2011 07:54 PM, bearophile wrote: Kai Meyer: Looking at std.algorithm, I think what you really want is minCount: http://www.d-programming-language.org/phobos/std_algorithm.html#minCount It's a bad design. Bye, bearophile minCount is, or the usage of minCount in his particular probl

Re: Minimum value in a range

2011-08-04 Thread bearophile
Kai Meyer: > Looking at std.algorithm, I think what you really want is minCount: > http://www.d-programming-language.org/phobos/std_algorithm.html#minCount It's a bad design. Bye, bearophile

Re: Minimum value in a range

2011-08-04 Thread Andrej Mitrovic
Cool. I've submitted a bug report for this, but maybe it's a duplicate.

Re: Minimum value in a range

2011-08-04 Thread Timon Gehr
Andrei Mitrovic wrote: > Does anyone know why putting this alias in module scope errors out?: > > import std.algorithm; > > alias reduce!((a, b){ return 1; }) foo; > > void main() > { > foo([1, 2, 3]); > } > > Error: delegate test.__dgliteral1!(int,int).__dgliteral1 is a nested > function and c

Re: Minimum value in a range

2011-08-04 Thread Kai Meyer
On 08/02/2011 06:03 AM, Andrej Mitrovic wrote: import std.algorithm; void main() { auto x = min([1, 2, 3]); // x would be 1 } min() isn't equipped to do this on a single range. What can I use instead? I haven't had my coffee yet. :) Looking at std.algorithm, I think what you really want

Re: Minimum value in a range

2011-08-02 Thread bearophile
Andrej Mitrovic: > import std.algorithm; > > void main() > { > auto x = min([1, 2, 3]); // x would be 1 > } > > min() isn't equipped to do this on a single range. What can I use > instead? I haven't had my coffee yet. :) See: http://d.puremagic.com/issues/show_bug.cgi?id=4705 Bye, bearoph

Re: Minimum value in a range

2011-08-02 Thread simendsjo
On 02.08.2011 14:42, Andrej Mitrovic wrote: Oh just realized I can use the much simpler: auto x = reduce!(min)([1, 2, 3]); Coffee is starting to kick in! Of course. I even had a lot of coffee running through my veins, so shame on me!

Re: Minimum value in a range

2011-08-02 Thread Andrej Mitrovic
Oh just realized I can use the much simpler: auto x = reduce!(min)([1, 2, 3]); Coffee is starting to kick in!

Re: Minimum value in a range

2011-08-02 Thread Andrej Mitrovic
Does anyone know why putting this alias in module scope errors out?: import std.algorithm; alias reduce!((a, b){ return 1; }) foo; void main() { foo([1, 2, 3]); } Error: delegate test.__dgliteral1!(int,int).__dgliteral1 is a nested function and cannot be accessed from reduce But this will

Re: Minimum value in a range

2011-08-02 Thread Andrej Mitrovic
On 8/2/11, simendsjo wrote: > assert(reduce!"min(a,b)"([1,2,3]) == 1); Thanks!

Re: Minimum value in a range

2011-08-02 Thread simendsjo
On 02.08.2011 14:03, Andrej Mitrovic wrote: import std.algorithm; void main() { auto x = min([1, 2, 3]); // x would be 1 } min() isn't equipped to do this on a single range. What can I use instead? I haven't had my coffee yet. :) import std.algorithm; void main() { assert(min(1, 2,

Minimum value in a range

2011-08-02 Thread Andrej Mitrovic
import std.algorithm; void main() { auto x = min([1, 2, 3]); // x would be 1 } min() isn't equipped to do this on a single range. What can I use instead? I haven't had my coffee yet. :)