Is there a way to search non-constant subsequences? E.g. the following should return [1 2] [7 8]
(m/search [1 2 4 5 7 8]
[(m/pred odd? ?x) (m/pred even? ?y) ...] [?x ?y])
But instead throws:
Zero or more patterns may not have references to unbound logic variables.
{:unbound #{?x ?y},
:syntax-trace
[((m/pred odd? ?x) (m/pred even? ?y) ...)
[(m/pred odd? ?x) (m/pred even? ?y) ...]]}Ah, okay, I didn’t know scan worked w/ multiple args!
You want scan.
(m/search [1 2 4 5 7 8]
(m/scan (m/pred odd? ?x) (m/pred even? ?y))
[?x ?y])
Which is basically sugar over
(m/search [1 2 4 5 7 8]
[_ ... (m/pred odd? ?x) (m/pred even? ?y) . _ ...]
[?x ?y])