pymbolic icon indicating copy to clipboard operation
pymbolic copied to clipboard

Mapper for deriving subexpressions as a list

Open redrossa opened this issue 5 years ago • 1 comments

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.

redrossa avatar Feb 03 '21 18:02 redrossa

You can probably subclass the WalkMapper to easily do what you want. It calls self.visit for every node.

inducer avatar Feb 03 '21 19:02 inducer