On Monday, 30 March 2015 at 18:07:18 UTC, matovitch wrote:
kmeans_example.d(79): Error: template std.algorithm.iteration.map

That error is easy: use points[].map!(test) instead of points.map.

Since points is a static array, it isn't a range. Static arrays can't be popped through. But if you slice it, then it yields a usable range for map.


The other problem though is the partial!(). It expects a template argument for the thing so it can make a new function right there at compile time... which doesn't work with a runtime variable.

The way I'd do it is just with a little hand written delegate. This will compile, for example:

      auto test = (ref Point p) => getRandomPoint(randVar, p);
      points[].map!(test);


and should do what you need.

Reply via email to