Improved variable definitions

This commit is contained in:
Eduard Urbach 2024-06-22 20:18:13 +02:00
parent 0b4b10ed4c
commit 57c9fc22d1
Signed by: eduard
GPG key ID: 49226B848C78F6C8
7 changed files with 48 additions and 22 deletions

View file

@ -54,6 +54,23 @@ func (expr *Expression) Close() {
pool.Put(expr)
}
// EachLeaf iterates through all leaves in the tree.
func (expr *Expression) EachLeaf(callBack func(*Expression) error) error {
if expr.IsLeaf() {
return callBack(expr)
}
for _, child := range expr.Children {
err := child.EachLeaf(callBack)
if err != nil {
return err
}
}
return nil
}
// RemoveChild removes a child from the expression.
func (expr *Expression) RemoveChild(child *Expression) {
for i, c := range expr.Children {