On 12/12/2012 05:47 AM, Zardoz wrote: > On Tuesday, 11 December 2012 at 17:50:31 UTC, Ali Çehreli wrote: >> On 12/11/2012 08:12 AM, Zardoz wrote: >> >> >> Could you please move MapIntegrator() to module-level. Then it should >> work. >> >> Ali > > I try it and now even with normal Map function give me errors with dmd ! > > public Entity MapIntegrator ( Entity me) { > me.Integrador3Orden (); > return me; > } > > void main() { > Entity[] objects; > ... > objects = array( map!MapIntegrator(objects) ); > ... > } > > With this error : > dmd -w -wi -version=SReduction simulator.d entity.d vector.d -ofreduceSim > simulator.d(194): Error: template std.algorithm.map!(MapIntegrator).map > does not match any function template declaration > /usr/include/dmd/phobos/std/algorithm.d(369): Error: template > std.algorithm.map!(MapIntegrator).map(Range) if > (isInputRange!(Unqual!(Range))) cannot deduce template function from > argument types !()(Entity[])
Strange. The following program works for me with dmd 2.060. It uses both the regular and parallel versions of map and reduce:
import std.array; import std.algorithm; import std.parallelism; struct Entity { void Integrador3Orden() {} } public Entity MapIntegrator ( Entity me) { me.Integrador3Orden (); return me; } void main() { Entity[] objects; objects = array( map!MapIntegrator(objects) ); objects = array(taskPool.map!MapIntegrator(objects)); int[] acelByObjs; int reduced = reduce!"a + b"(0, acelByObjs); reduced = taskPool.reduce!"a + b"(0, acelByObjs); } Ali