Open MilesCranmer opened 4 months ago
I think the generalization to more than 2 children would be best attempted with StaticArrays.MArray. So you could have a field
StaticArrays.MArray
struct Node{T,N} degree::UInt8 ... _children::MVector{Node{T,N},N} end
The beauty of this is you could still have undefined values (https://discourse.julialang.org/t/how-to-initialize-an-empty-staticarray/69942/11?u=milescranmer) and the max number of children would still be a compile time constant.
And calling children(node) could return a Vector according to the degree of the node. (Though we would still want to have special methods for each degree).
children(node)
Vector
degree
Similarly, for OperatorEnum, it could be a tuple of tuples up to the maximum arity.
OperatorEnum
@gca30 interested to hear your thoughts
I think the generalization to more than 2 children would be best attempted with
StaticArrays.MArray
. So you could have a fieldThe beauty of this is you could still have undefined values (https://discourse.julialang.org/t/how-to-initialize-an-empty-staticarray/69942/11?u=milescranmer) and the max number of children would still be a compile time constant.
And calling
children(node)
could return aVector
according to thedegree
of the node. (Though we would still want to have special methods for each degree).Similarly, for
OperatorEnum
, it could be a tuple of tuples up to the maximum arity.@gca30 interested to hear your thoughts