Yield from function?

cym13 via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jan 30 14:04:09 PST 2017


On Monday, 30 January 2017 at 18:48:10 UTC, Ali Çehreli wrote:
> On 01/30/2017 03:03 AM, Profile Anaysis wrote:
> > I need to yield from a complex recursive function too allow
> visualizing
> > what it is doing.
> >
> > e.g., if it is a tree searching algorithm, I'd like to yield
> for each
> > node so that the current state can be shown visually.
>
> I used tree iteration as a Generator example here:
>
>   http://ddili.org/ders/d.en/fibers.html
>
> It's in the code where the function 'byNode' appears. (The 
> example builds on an earlier tree iteration code in the same 
> chapter.)
>
> Ali

BTW the alias to avoid a name conflic on "Generator" isn't 
necessary anymore with the last version of phobos (as shipped 
with DMDv2.073.0). However it's still conflicting with the latest 
version of LDC available on my system (1.0.0, based on 
DMDv2.070.2) so maybe letting it be in the example a bit longer 
is appropriate. Otherwise I believe you'll agree that removing it 
would make it easier for the beginners.


More information about the Digitalmars-d-learn mailing list