Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save disconcision/5c80494531f7ae0b8c5ac5980ffc0395 to your computer and use it in GitHub Desktop.
Save disconcision/5c80494531f7ae0b8c5ac5980ffc0395 to your computer and use it in GitHub Desktop.
this is regarding this expander:
https://github.com/disconcision/containment-patterns
which I am trying to improve
simple containment patterns (finds first instance of internal pattern):
(match '(1 (5 ($ 3 6)) 7)
[(⋱ c `($ ,x ,y))
(⋱ c `($, (+ x y)))])
> '(1 (5 ($ 9)) 7)
multi-hit patterns (my current syntax):
(match '(1 (5 ($ 3 6)) 7 ($ 5 9))
[(⋱+ c `($ ,x ,y))
(⋱+ c [x y] `($, (+ x y)))])
> '(1 (5 ($ 9)) 7 ($ 14))
but I just want to write:
(match '(1 (5 ($ 3 6)) 7 ($ 5 9))
[(⋱+ c `($ ,x ,y))
(⋱+ c `($, (+ x y)))])
the way i am currently thinking of doing this is capturing the identifiers bound in the internal pattern (in above example, [x y]), and then communicating them to the template. i can do the former but not the latter.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment