Chris Cain:
InputRange!Tree walk()
{
return inputRangeObject(chain(
[this],
children.map!(a=a.walk())().joiner()));
}
I have used your nice idea to create another partial D solution
for this task:
http://rosettacode.org/wiki/Tree_traversal#D
On 10/30/13, Chris Cain clc...@uncg.edu wrote:
I'm not confident that this is the most efficient way, but it
works.
It allocates, I'm looking for a lazy range. I would be surprised that
such a common task as iterating a tree is not possible without using
classes and workarounds.
Am 30.10.2013 15:58, schrieb Andrej Mitrovic:
On 10/30/13, Chris Cain clc...@uncg.edu wrote:
I'm not confident that this is the most efficient way, but it
works.
It allocates, I'm looking for a lazy range. I would be surprised that
such a common task as iterating a tree is not possible
On Wednesday, 30 October 2013 at 14:58:21 UTC, Andrej Mitrovic
wrote:
It allocates, I'm looking for a lazy range. I would be
surprised that
such a common task as iterating a tree is not possible without
using
classes and workarounds.
It allocates, but it's still a lazy range. It only
On Wednesday, 30 October 2013 at 12:55:41 UTC, bearophile wrote:
I have used your nice idea to create another partial D solution
for this task:
http://rosettacode.org/wiki/Tree_traversal#D
... snip ...
Very cool! It's pretty close to being done. I'd have to give some
real thought to how a
On Wednesday, 30 October 2013 at 16:50:33 UTC, Chris Cain wrote:
you would avoid allocations.
Actually, let me clarify. You'd avoid *those* allocations.
inputRangeObject allocates a class. Unfortunately, I'm not
certain it's possible to do this cleanly without such a thing
using
On Wed, Oct 30, 2013 at 1:55 PM, bearophile bearophileh...@lycos.comwrote:
alias VisitRange(T) = InputRange!(const Tree!T);
Does that syntax come with DMD 2.064? The (T) part, I mean.
On Wednesday, 30 October 2013 at 17:31:10 UTC, Philippe Sigaud
wrote:
On Wed, Oct 30, 2013 at 1:55 PM, bearophile
bearophileh...@lycos.comwrote:
alias VisitRange(T) = InputRange!(const Tree!T);
Does that syntax come with DMD 2.064? The (T) part, I mean.
Yes.
On 10/30/13, Philippe Sigaud philippe.sig...@gmail.com wrote:
Does that syntax come with DMD 2.064? The (T) part, I mean.
Yes.
Glad to see you here btw, do you have your own solution to the problem?
On Wed, Oct 30, 2013 at 7:09 PM, Andrej Mitrovic andrej.mitrov...@gmail.com
wrote:
On 10/30/13, Philippe Sigaud philippe.sig...@gmail.com wrote:
Does that syntax come with DMD 2.064? The (T) part, I mean.
Yes.
Ah, that's cool! I've been waiting for that one for years.
Glad to see you
Instead of the usual opApply approach, how would you implement an auto
return walker function *without* defining a special external struct
that holds all the logic? In other words, using existing Phobos
functionality only, composing functions like map and chain. Example
code which isn't correct:
Here's the code:
InputRange!Tree walk()
{
return inputRangeObject(chain(
[this],
children.map!(a=a.walk())().joiner()));
}
Result:
---
[root, root.1, root.1.1, root.1.2, root.2, root.2.1, root.2.2]
---
It's a bit confusing to explain how I
12 matches
Mail list logo