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

Fix issue #8: Add support for Some(*patterns) that matches subsequences #9

Merged
merged 17 commits into from Jan 2, 2022

Conversation

scravy
Copy link
Owner

@scravy scravy commented Jan 1, 2022

This allows Some(*) to match subsequences.

Previously Some(...) would only match individiual items, i.e. the pattern [0, Some(1), 2] would match the value [0, 1, 1, 1, 2]. Compared with a regex on strings this would be like 01*2 but the repetition here could not be applied to subsequences 0(12)*3. This pull request introduces the ability for Some(*) to take multiple patterns which it then tries to match as a sequence within: [0, Some(1, 2), 3] would now match the value [0, 1, 2, 1, 2, 3]. This could not be expressed before.

Note that the new syntax is different from Some([1, 2]) as this would match items which are themselves lists, i.e. [0, [1, 2], [1, 2], 3].

@scravy scravy self-assigned this Jan 1, 2022
@scravy scravy linked an issue Jan 1, 2022 that may be closed by this pull request
@scravy scravy changed the title Fix issue 8: Add support for Some(*patterns) that matches subsequences Fix issue #8: Add support for Some(*patterns) that matches subsequences Jan 1, 2022
@scravy scravy force-pushed the fix-issue-8 branch 2 times, most recently from a802445 to f7a70e1 Compare January 2, 2022 04:36
@scravy scravy marked this pull request as ready for review January 2, 2022 05:07
@scravy scravy merged commit 9729c5a into main Jan 2, 2022
@scravy scravy deleted the fix-issue-8 branch January 2, 2022 05:11
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

Successfully merging this pull request may close these issues.

Question: Is it possible to match a subsequence multiple times?
1 participant