<html>
    <head>
      <base href="http://bugzilla.gdcproject.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Fails to compile std.parallelism.reduce"
   href="http://bugzilla.gdcproject.org/show_bug.cgi?id=122#c2">Comment # 2</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Fails to compile std.parallelism.reduce"
   href="http://bugzilla.gdcproject.org/show_bug.cgi?id=122">bug 122</a>
              from <span class="vcard"><a class="email" href="mailto:russel@winder.org.uk" title="Russel Winder <russel@winder.org.uk>"> <span class="fn">Russel Winder</span></a>
</span></b>
        <pre>It is the variant of my π by Quadrature example that David Simcha and I came up
with whilst he was writing parallelism.d:

/*
 *  A D program to calculate π using quadrature as a parallel reduce of
individual expression evaluations
 *  with no manual batching.
 *
 *  Copyright © 2011–2013  Russel Winder
 */

//  This version originally due to David Simcha, stemming from various emails
on the various D email lists
//  and reified in the documentation for std.parallelism:
<a href="http://dlang.org/phobos/std_parallelism.html">http://dlang.org/phobos/std_parallelism.html</a>,
//  <a href="http://cis.jhu.edu/~dsimcha/d/phobos/std_parallelism.html">http://cis.jhu.edu/~dsimcha/d/phobos/std_parallelism.html</a>

import std.algorithm;
import std.datetime;
import std.parallelism;
import std.range;

import outputFunctions;

int main(immutable string[] args) {
  immutable n = 1000000000;
  immutable delta = 1.0 / n;
  StopWatch stopWatch;
  stopWatch.start();
  //  There is a problem using a lambda function here.  David Simcha reports it
is a consequence of issue
  //  5710 <a href="http://d.puremagic.com/issues/show_bug.cgi?id=5710">http://d.puremagic.com/issues/show_bug.cgi?id=5710</a>.  Live with this
and use the string syntax
  //  for specifying a lambda function.
  //immutable pi = 4.0 * delta * taskPool.reduce !((a, b) { return a + b; }) (
  //immutable pi = 4.0 * delta * taskPool.reduce !((a, b) => a + b) (
  immutable pi = 4.0 * delta * taskPool.reduce!"a + b"(
      map!((int i) { immutable x = (i - 0.5) * delta; return 1.0 / (1.0 + x *
x); })(iota(n)));
  stopWatch.stop();
  immutable elapseTime = stopWatch.peek().hnsecs * 100e-9;
  output(__FILE__, pi, n, elapseTime);
  return 0;
}</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are watching all bug changes.</li>
      </ul>
    </body>
</html>