You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm now using a modified version of mksub which returns the full matching collection and tries to maintain the seq/vector distinction of the input. Also, I wanted to match exact sequences so I added sp/end to the sub-rule so that it would reject any extra stuff. I take an optional predicate so that I can restrict my match to vector? or seq? in cases where that matters. You're welcome to use any or all of these changes if you like them.
I'm now using a modified version of mksub which returns the full matching
collection and tries to maintain the seq/vector distinction of the input.
Also, I wanted to match exact sequences so I added sp/end to the sub-rule
so that it would reject any extra stuff. I take an optional predicate so
that I can restrict my match to vector? or seq? in cases where that
matters. You're welcome to use any or all of these changes if you like
them.
The return value from mksub is not the full matching collection. This caused problems for me especially when matching vectors of one item.
user=> (require '[squarepeg.core :as sp])
nil
user=> (def v1 (sp/mksub (sp/mklit 1)))
'user/v1
user=> (v1 [[1]] {} {} {})
{:i (), :b {}, :r 1, :s [1], :m {}}
; expected :r [1]
user=> (def v12 (sp/mkseq (sp/mksub (sp/mklit 1)) (sp/mksub (sp/mklit 2))))
'user/v12
user=> (v12 [[1] [2]] {} {} {})
{:i (), :b {}, :r [1 2], :s [1 2], :m {}}
; expected :r [[1] [2]]
I'm now using a modified version of mksub which returns the full matching collection and tries to maintain the seq/vector distinction of the input. Also, I wanted to match exact sequences so I added sp/end to the sub-rule so that it would reject any extra stuff. I take an optional predicate so that I can restrict my match to vector? or seq? in cases where that matters. You're welcome to use any or all of these changes if you like them.
The text was updated successfully, but these errors were encountered: