You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
They basically allow the programmer to make every function into a phobos range.
Instead of iterating through stuff and calculating things you could simply use a generator which will only calculate the first thing and then return that one. Once another one is requested it will start from where it stopped.
importstd.concurrency;
importstd.stdio;
importstd.range;
autogenerateIntegers()
{
returnnew Generator({
int i = 0;
while(true) // wont get stuck here
yield(i++); // because of yield
});
}
voidmain()
{
generateIntegers().take(50).each!writeln;
// Will print 0-49 to the console
}
https://dlang.org/library/std/concurrency/generator.html
They basically allow the programmer to make every function into a phobos range.
Instead of iterating through stuff and calculating things you could simply use a generator which will only calculate the first thing and then return that one. Once another one is requested it will start from where it stopped.
More information in other languages: http://www.dotnetperls.com/yield
The text was updated successfully, but these errors were encountered: