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

Condition, PatternTest, Alternatives #11

Open
anandijain opened this issue Oct 22, 2023 · 0 comments
Open

Condition, PatternTest, Alternatives #11

anandijain opened this issue Oct 22, 2023 · 0 comments

Comments

@anandijain
Copy link
Owner

these should be the next Pattern objects to handle
i think alternatives is easy. It should be as simple as iterating the arguments to Alternatives head calling match on each one

Condition im less sure about bc of f[x_] := ppp[x] /; x > 0 giving

Hold[SetDelayed[f[Pattern[x, Blank[]]], Condition[ppp[x], Greater[x, 0]]]] 

Where the Condition does not wrap the Pattern. I think that means you see the match but in the evaluator or wherever the rule application is, you then need to check the head of the rhs to see if its a condition and bail if its not True

in order of importance, Condition is clearly the most useful

PatternTest is lowest priority I think

I want Condition support so that I could write

In[59]:= MatchQ[{a,b,c},{elems__} /; SameQ @@ (Head /@ {elems})]

Out[59]= True

In[60]:= MatchQ[{a,b,c[d]},{elems__} /; SameQ @@ (Head /@ {elems})]

Out[60]= False
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

1 participant