pi program
mzfhhhh via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Fri Sep 25 02:14:37 PDT 2015
> If we worry about the string form and instead try:
>
> double reduce_string_loop() {
> return reduce!"1.0 / (a * a)"(iota(1, 100));
> }
>
> double reduce_function_loop() {
> return reduce!((n) => 1.0 / (n * n))(iota(1, 100));
> }
>
it should be write :
double reduce_loop() {
//return iota(1, 100).map!"1.0 / (a * a)".sum;
return iota(1, 100).reduce!"a + 1.0 / (b * b)";
}
More information about the Digitalmars-d-learn
mailing list