Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gem: Using Fibers with ranges #133

Closed
wilzbach opened this issue May 18, 2016 · 2 comments
Closed

gem: Using Fibers with ranges #133

wilzbach opened this issue May 18, 2016 · 2 comments
Labels

Comments

@wilzbach
Copy link
Member

This is one of my favorite features in D, but it took me a while to discover this.
This allows one to write pretty sophisticated lazy algorithms by just saving keeping a reference to the stack.
Ali had a great talk about this year -> http://dconf.org/2016/talks/cehreli.html

import std.concurrency: Generator,yield;
auto r = new Generator!int(
{
    foreach (i; 1 .. 10)
        yield(i);
});

import std.range: iota;
import std.algorithm.comparison: equal;
assert(r.equal(iota(1, 10)));

https://dlang.org/library/std/concurrency/generator.html

@stonemaster
Copy link
Collaborator

That's a good one. There is already fiber's section maybe it fits there.

@wilzbach
Copy link
Member Author

This issue was moved to dlang-tour/english#7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants