Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mapper for deriving subexpressions as a list #31

Open
redrossa opened this issue Feb 3, 2021 · 1 comment
Open

Mapper for deriving subexpressions as a list #31

redrossa opened this issue Feb 3, 2021 · 1 comment

Comments

@redrossa
Copy link
Contributor

redrossa commented Feb 3, 2021

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
Copy link
Owner

inducer commented Feb 3, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants