From 9dc875e5e67835ad1974b52491a4b7af072d52a3 Mon Sep 17 00:00:00 2001 From: Nao Pross Date: Sat, 2 Mar 2024 18:17:10 +0100 Subject: Add Expr.node to ease iteration expression tree node children --- mdpoly/abc.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mdpoly/abc.py b/mdpoly/abc.py index 7ac21dd..c60311a 100644 --- a/mdpoly/abc.py +++ b/mdpoly/abc.py @@ -33,6 +33,9 @@ class Expr(Protocol): name = self.__class__.__qualname__ return f"{name}(left={self.left}, right={self.right})" + def nodes(self) -> Sequence[Self]: + return self.left, self.right + def leaves(self) -> Sequence[Leaf]: if isinstance(self.left, Leaf): yield self.left -- cgit v1.2.1