pymbolic
pymbolic copied to clipboard
Mapper for deriving subexpressions as a list
Is there a mapper for listing all subexpressions of an expression? For example, x + 2*y becomes [x + 2*y, 2*y, x, y], sorted based on precedence. Otherwise, if you like the idea, I'm willing to create a PR for it.
You can probably subclass the WalkMapper to easily do what you want. It calls self.visit for every node.