Minimum value in a range

Kai Meyer kai at unixlords.com
Thu Aug 4 14:32:34 PDT 2011


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 is minCount:
http://www.d-programming-language.org/phobos/std_algorithm.html#minCount



More information about the Digitalmars-d-learn mailing list