Add [SIMPLE-]VECTOR* and SEQUENCE[*] patterns#82
Add [SIMPLE-]VECTOR* and SEQUENCE[*] patterns#82scymtym wants to merge 3 commits intom2ym:masterfrom
Conversation
|
Rebased for master changes. |
|
Is there a reason this wasn't merged? It opens up the possibility for binary patterns as suggested in #29 too. |
|
From his recent comment, I guess m2ym just does not have enough time to handle the merge requests (it even contains conflicts). |
|
@guicho271828 The (match #(1 2 3 4)
((vector* a b c) (list a b c)))
;=> (1 2 #(3 4))Trivia's (match #(1 2 3 4)
((vector* a b c) (list a b c)))
;=> (1 2 3) |
|
@jorams I see. If I'm getting right, it requires creating a displaced array every time the matcher is invoked. It requires consing, and I don't really like it... Making a displaced array would be out of the scope of a pattern matcher. You know, wouldn't that be unnatural to use In contrast, prefixing the access pattern is possible, see Inline pattern. Although the post mentions (defpattern skip (n)
`(inline ,@(loop repeat n collect '_)))
(match v
((vector (skip 100) a b c) ...)) |
|
This is addressed in Trivia. |
I added patterns
[simple-]vector*which relate to[simple-]vectorlikelist*tolistsequence[*]which behave like the list and vector patterns but match sequencesI placed the pattern designators in the
optimapackage, butoptima.extramay be the proper place.The second commit was necessary because I realized that, like
list*, the{[simple-]vector,sequence}*patterns should require at least one argument.Minimal unit tests and
README.mdchanges are included.