inducer / pymbolic

A simple package to do symbolic math (focus on code gen and DSLs)
http://mathema.tician.de/software/pymbolic
Other
108 stars 25 forks source link

Mapper for deriving subexpressions as a list #31

Open redrossa opened 3 years ago

redrossa commented 3 years ago

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.

inducer commented 3 years ago

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