What am I doing wrong here - canFind with iota is not working

bearophile via Digitalmars-d digitalmars-d at puremagic.com
Thu Feb 26 04:56:54 PST 2015


Laeeth Isharc:

> Ie I think people diagnosed the problem, but what is the 
> solution...

A possible solution:


void main() @safe {
     import std.stdio, std.range, std.algorithm, std.math;

     immutable float oneDegree = (PI / 180.0f);
     immutable float first = -(oneDegree * 10.0f);
     immutable float second = (oneDegree * 10.0f);
     immutable float step = 0.000001f;
     immutable float[] r = iota(first, second, step).array;

     //r.writeln;

     immutable float item = 0.174531f;
     r.canFind!q{ feqrel(cast()a, cast()b) >= 21 }(item).writeln;
}


Bye,
bearophile


More information about the Digitalmars-d mailing list