taskPool.map using functions with more than one input
    Joseph Rushton Wakeling 
    joseph.wakeling at webdrake.net
       
    Wed Nov 14 09:31:07 PST 2012
    
    
  
Is it possible to use taskPool.map with functions that take more than one input?
Consider the following code which uses map to convert a given value to its sum 
with another number:
       import std.algorithm, std.parallelism, std.range, std.stdio;
       real pairsum(real x, real y)
       {
             writeln("Calculating sum of ", x, " + ", y);
             return x + y;
       }
       void main()
       {
             real x = 3.0;
             auto y = iota(0.0, 1.0, 0.05);
             auto psums = map!(a => pairsum(x, a))(y);
             foreach(s; psums)
                   writeln(s);
       }
Simply replacing map! with taskPool.map! results in a compilation error due to 
the use of the a => notation.  But how else to tell it the function arguments 
that should _not_ be iterated over?  Or is taskPool.map! limited to 
single-argument functions?
    
    
More information about the Digitalmars-d-learn
mailing list