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

Question/Feature request #97

Closed
thisfred opened this issue Sep 18, 2019 · 4 comments
Closed

Question/Feature request #97

thisfred opened this issue Sep 18, 2019 · 4 comments

Comments

@thisfred
Copy link

I was trying out comby and wanted to do the following refactoring:

dict(foo=bar,baz=qux)

=>

{"foo": bar, "baz": qux}

but I can't find a way to repeatedly apply a pattern within a particular scope. Am I missing how to do this, or is this not currently possible?

@rvantonder
Copy link
Member

It's possible, but not documented yet :) What you do is use a nested rewrite rule like this: https://bit.ly/2LY8N3z

I'll update the docs in the advanced/exerpimental feature section. For future questions feel free to head over to gitter: https://gitter.im/comby-tools/community. I appreciate this question, it's helped me to refer people to gitter when starting an issue in case it's about writing a pattern. Thanks for popping in!

@rvantonder
Copy link
Member

For posterity:

dict(:[args]) -> {:[args]}

where rewrite :[args] { 
  ":[[k]]=:[[v]]" -> "\":[k]\": :[v]"
}

:)

@thisfred
Copy link
Author

That's awesome, thank you!

@rvantonder
Copy link
Member

You are very welcome. I've updated the docs, and used your example :)

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