We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Is there a way to match a pattern like [_, 0, _] only if the two _s are equal, and if they aren't continue to the next pattern?
[_, 0, _]
_
The text was updated successfully, but these errors were encountered:
Not nicely as far as I can tell.
the best I could come up with is:
def check_seq(seq): return len(seq)==3 and seq[1] == 0 and seq[0]==seq[2] def match_seq(seq): return 2* seq[0]
and then have the pattern just be check_seq...then you end up with: check_seq, lambda a: match_seq(a)
check_seq, lambda a: match_seq(a)
This isn't great because you loose the patterns but it is compact.
Sorry, something went wrong.
No branches or pull requests
Is there a way to match a pattern like
[_, 0, _]
only if the two_
s are equal, and if they aren't continue to the next pattern?The text was updated successfully, but these errors were encountered: