November 14, 2012
Is it possible to use 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)

Simply replacing map! with! 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! limited to single-argument functions?
Top | Discussion index | About this forum | D home