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
Add ‘match?’, a pattern-matching predicate #1690
Comments
This seems like a good idea, but I'm not sure about the name. What about
matches?
…On Fri, May 12, 2017, 11:46 AM Leandro Facchinetti ***@***.***> wrote:
*FEATURE PROPOSAL*
Add match? to racket/match. It is given a subject expression and a
pattern, if the expression evaluates to a value that matches the pattern,
then match? returns #t, otherwise it returns #f. Here’s a proposed
implementation:
#lang racket
(require syntax/parse/define)
(define-simple-macro (match? subject:expr pattern:expr)
(match subject
[pattern #t]
[_ #f]))
(match? `(a b) `(,c ,d)) # => #t
------------------------------
If you agree with this proposal, please let me know and I’ll send a pull
request.
Thanks.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#1690>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAO78y51FGzkCcAtE7m1qAc2TFE6YEpIks5r5H7RgaJpZM4NZdcT>
.
|
I thought |
We need to consider potential conflicts. Particularly interesting is that it seems |
Well, that wasn't any more of thing in the past than now, but it suggests we should use that name. But we do need to make sure there aren't conflicts. |
Any other conflicts? This would be a very handy syntax :) |
It is exported by redex: http://docs.racket-lang.org/search/index.html?q=match%3F |
|
Right, I think we should have a new package that provides the remaining components of |
Having to install and require a separate package would cancel out the small convenience that |
We likely can't add it to I think we should get to a point with the pkg ecosystem where adding a new dependency for something this small is a reasonable choice. Maybe we're not there yet, though. |
I agree with Sam's sentiment about small packages (both that it would be nice and that perhaps we aren't there). Is there another name to consider? |
|
I’d be happy if |
FEATURE PROPOSAL
Add
match?
toracket/match
. It is given a pattern and a subject expression, if the expression evaluates to a value that matches the pattern, thenmatch?
returns#t
, otherwise it returns#f
. Also, as an alternative form,match?
could be given just a pattern, in which case it returns a predicate function.Here’s a proposed implementation:
This design follows
redex-match?
.If you agree with this proposal, please let me know and I’ll send a pull request.
Thanks.
The text was updated successfully, but these errors were encountered: