Fun with recursions
Steven Schveighoffer
schveiguy at yahoo.com
Fri Feb 21 17:52:01 UTC 2020
On Friday, 21 February 2020 at 16:49:15 UTC, Andrej Mitrovic
wrote:
> It's very simplistic, but I think it could easily be expanded
> upon. And it could use a better name. It's possible I'm not
> seeing an easier solution though, so destroy if you must.
This is pretty heavy handed. All that is needed is a stack and a
recursion function.
This works, and returns a range of Node, then you have to map to
what you actually want (reasonable to me instead of leaving the
recursion up to introspection):
https://gist.github.com/schveiguy/962e36cea6a979a47b708cb4335f9f82
I don't love that chain call to get the first node in there. But
I don't know your requirements, so...
-Steve
More information about the Digitalmars-d
mailing list