mk: selecto — choose element + rest of list
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 29s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 29s
Classic miniKanren relation. (selecto x rest l) holds when l contains x at any position with `rest` being everything else. Direct base case (l = (x . rest)) plus the skip-head recursion that threads the head through to the result rest. Run modes: enumerate every (x, rest) split; recover rest given an element; recover an element given the rest; (and ground/all combinations). 6 new tests, 411/411 cumulative.
This commit is contained in:
@@ -82,6 +82,14 @@
|
||||
(appendo front-and-s back l)
|
||||
(appendo front s front-and-s))))
|
||||
|
||||
(define
|
||||
selecto
|
||||
(fn
|
||||
(x rest l)
|
||||
(conde
|
||||
((conso x rest l))
|
||||
((fresh (a d r) (conso a d l) (conso a r rest) (selecto x r d))))))
|
||||
|
||||
(define
|
||||
lengtho
|
||||
(fn
|
||||
|
||||
Reference in New Issue
Block a user