Generators in D
Piotr Szturmaj
bncrbme at jadamspam.pl
Tue May 10 17:05:12 PDT 2011
Hi,
I've written some proof of concept code of generator pattern, example:
void genSquares(out int result, int from, int to)
{
foreach (x; from .. to + 1)
{
yield!result(x * x);
}
}
void main(string[] argv)
{
foreach (sqr; generator(&genSquares, 10, 20))
writeln(sqr);
}
posted on github:
https://github.com/pszturmaj/dgenerators
Thanks to Sean Kelly who wrote Fiber code.
Piotr
More information about the Digitalmars-d
mailing list