digitalmars.D.learn - Lazy Range of Graph Links
- =?UTF-8?B?Tm9yZGzDtnc=?= (31/31) Feb 16 2016 In my knowledge hypergraph I currently have a
- Andrea Fontana (4/35) Feb 16 2016 Something like this:
- =?UTF-8?B?Tm9yZGzDtnc=?= (5/8) Feb 16 2016 Thanks.
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.
Feb 16 2016
On Tuesday, 16 February 2016 at 08:04:29 UTC, Nordlöw wrote: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.Something like this: http://dpaste.dzfl.pl/de73cb4e7ac0 ?
Feb 16 2016
On Tuesday, 16 February 2016 at 08:45:42 UTC, Andrea Fontana wrote:Something like this: http://dpaste.dzfl.pl/de73cb4e7ac0 ?Thanks. Note that this can be simplified by using a variadic version of zip...
Feb 16 2016