Lazy Range of Graph Links
Nordlöw via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Feb 16 00:04:29 PST 2016
In my knowledge hypergraph I currently have a
struct Path
{
Node start;
Step[] steps;
}
struct Step
{
Fact fact;
Node node;
}
where Node and Fact a reference types (class).
I now want to implement
auto byLink(Path path);
so that it returns a lazy range of Links where
struct Link
{
Node source;
Fact fact;
Node destination;
}
In other Words, if I have a Path instance describing
N1 >=F1=> N2 >=F2=> N3
where
start: F1
and
steps: [(F1, N2), (F2, N3)]
I want byLink to return
[(N1, F1, N2), (N2, F2, N3)]
How do accomplish this?
I'm guessing std.range.zip should play a role here.
More information about the Digitalmars-d-learn
mailing list