add scale node
This commit is contained in:
@@ -11,6 +11,7 @@ new_key_type! { pub struct NodeId; }
|
|||||||
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
|
||||||
pub enum Node<V: Var> {
|
pub enum Node<V: Var> {
|
||||||
Leaf(V),
|
Leaf(V),
|
||||||
|
Scale(NodeId, i32),
|
||||||
Sum(NodeId, NodeId),
|
Sum(NodeId, NodeId),
|
||||||
Prod(NodeId, NodeId),
|
Prod(NodeId, NodeId),
|
||||||
}
|
}
|
||||||
@@ -19,6 +20,7 @@ impl<V: Var> Node<V> {
|
|||||||
pub fn children(&self) -> impl Iterator<Item = NodeId> {
|
pub fn children(&self) -> impl Iterator<Item = NodeId> {
|
||||||
match self {
|
match self {
|
||||||
Node::Leaf(_) => [None, None],
|
Node::Leaf(_) => [None, None],
|
||||||
|
Node::Scale(n,_) => [Some(*n), None],
|
||||||
Node::Sum(l, r) | Node::Prod(l, r) => [Some(*l), Some(*r)],
|
Node::Sum(l, r) | Node::Prod(l, r) => [Some(*l), Some(*r)],
|
||||||
}
|
}
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
|||||||
Reference in New Issue
Block a user