Minimum value in a range

simendsjo simendsjo at gmail.com
Tue Aug 2 05:09:28 PDT 2011


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, 3) == 1);
     assert(reduce!"min(a,b)"([1,2,3]) == 1);
}



More information about the Digitalmars-d-learn mailing list