example suggestion: tree with a variable number of children
Anton-4 opened this issue · comments
Starting point:
NodeID : U64
Node : { value: Str, children : List NodeID}
tree : Dict NodeID Node
tree = Dict.empty {}
|> Dict.insert 0 { value: "hey", children: [1]}
|> Dict.insert 1 { value: "hey!", children: []}
Brendan also suggested a type like this, which could look nicer/simpler:
Node: [Element { branch: List Node, ...}]
We may want to make a simple example and one optimized for performance but we can worry about that later.
@Anton-4 is this similar to https://github.com/roc-lang/examples/tree/main/examples/GraphTraversal?
Yes, although I'd keep it simpler here and only show how to make a tree datastructure, without any functions.