mk: prefixo + suffixo — appendo-derived sublist relations
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 40s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 40s
Two-line definitions over appendo: (prefixo p l) ≡ ∃rest. (appendo p rest l) (suffixo s l) ≡ ∃front. (appendo front s l) Both enumerate all prefixes/suffixes when called with a fresh first arg, and serve as decision relations when called with both grounded. 9 new tests, 398/398 cumulative.
This commit is contained in:
76
lib/minikanren/tests/prefix-suffix.sx
Normal file
76
lib/minikanren/tests/prefix-suffix.sx
Normal file
@@ -0,0 +1,76 @@
|
||||
;; lib/minikanren/tests/prefix-suffix.sx — appendo-derived sublist relations.
|
||||
|
||||
(mk-test
|
||||
"prefixo-empty"
|
||||
(run* q (prefixo (list) (list 1 2 3)))
|
||||
(list (make-symbol "_.0")))
|
||||
|
||||
(mk-test
|
||||
"prefixo-full"
|
||||
(run*
|
||||
q
|
||||
(prefixo
|
||||
(list 1 2 3)
|
||||
(list 1 2 3)))
|
||||
(list (make-symbol "_.0")))
|
||||
|
||||
(mk-test
|
||||
"prefixo-partial"
|
||||
(run*
|
||||
q
|
||||
(prefixo
|
||||
(list 1 2)
|
||||
(list 1 2 3 4)))
|
||||
(list (make-symbol "_.0")))
|
||||
|
||||
(mk-test
|
||||
"prefixo-mismatch-fails"
|
||||
(run*
|
||||
q
|
||||
(prefixo
|
||||
(list 1 3)
|
||||
(list 1 2 3)))
|
||||
(list))
|
||||
|
||||
(mk-test
|
||||
"prefixo-enumerates-all"
|
||||
(run* q (prefixo q (list 1 2 3)))
|
||||
(list
|
||||
(list)
|
||||
(list 1)
|
||||
(list 1 2)
|
||||
(list 1 2 3)))
|
||||
|
||||
(mk-test
|
||||
"suffixo-empty"
|
||||
(run* q (suffixo (list) (list 1 2 3)))
|
||||
(list (make-symbol "_.0")))
|
||||
|
||||
(mk-test
|
||||
"suffixo-full"
|
||||
(run*
|
||||
q
|
||||
(suffixo
|
||||
(list 1 2 3)
|
||||
(list 1 2 3)))
|
||||
(list (make-symbol "_.0")))
|
||||
|
||||
(mk-test
|
||||
"suffixo-partial"
|
||||
(run*
|
||||
q
|
||||
(suffixo
|
||||
(list 2 3)
|
||||
(list 1 2 3)))
|
||||
(list (make-symbol "_.0")))
|
||||
|
||||
(mk-test
|
||||
"suffixo-enumerates-all"
|
||||
(run* q (suffixo q (list 1 2 3)))
|
||||
(list
|
||||
(list 1 2 3)
|
||||
(list 2 3)
|
||||
(list 3)
|
||||
(list)))
|
||||
|
||||
(mk-tests-run!)
|
||||
Reference in New Issue
Block a user