Mapping with partial
matovitch via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Mar 30 11:07:18 PDT 2015
Hi again,
I have this simple toy code :
import point;
import std.random;
import std.algorithm;
import std.functional;
void getRandomPoint(R)(R randVar, ref Point p)
{
p.x = randVar;
p.y = randVar;
p.z = randVar;
}
void main()
{
Point[500] points;
auto randVar = uniform(0.0f, 1.0f);
alias test = partial!(getRandomPoint, randVar);
points.map!(test);
}
And get the following error :
kmeans_example.d(79): Error: template std.algorithm.iteration.map
cannot deduce function from argument types
!(partial)(Point[500]), candidates are:
/usr/include/dmd/phobos/std/algorithm/iteration.d(434):
std.algorithm.iteration.map(fun...) if (fun.length >= 1)
Btw, I don't understand why :
auto test = partial!(getRandomPoint, randVar);
dont work...partial doesnt return a delegate it seems...:/
More information about the Digitalmars-d-learn
mailing list