-
Notifications
You must be signed in to change notification settings - Fork 22
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
Binding type/predicate pattern #103
Comments
Oops, after fumbling around a bit more with
Not sure if this is the best way to do it but it seems to work with my use case! |
oh yes, nice idea. Why I did not think about this? Indeed I often write code as below very often; The current Appreciated if you try to extend the definition of (match s
((list (and x (type string)) y) ... ))
;; proposed:
(match s
((list (type string x) y) ... )) |
Oh wow, I didn't realize you could use I'll work on a PR to extend the |
I apologize if this isn't the right place to post this question!
I'm looking for a type predicate subpattern that also binds the value it's run on.
My use case is something like this: I want to only match lists that start with a string (or more generally, their first element satisfies some predicate) and also bind the first element of the list.
For simple patterns, something like this works:
but ideally I'd like to not have to manually do the
(car x)
.The text was updated successfully, but these errors were encountered: