Files
rose-ash/lib/minikanren/tests/repeato-concato.sx
giles c2b238635f
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 25s
mk: repeato + concato
repeato: produces (or recognizes) a list of n copies of a value, with n
Peano-encoded. Runs forward, backward (recover the count from a uniform
list), and bidirectionally.

concato: fold-appendo over a list-of-lists. (concato (list (list 1 2)
(list) (list 3 4 5)) q) -> ((1 2 3 4 5)).

10 new tests, 378/378 cumulative.
2026-05-08 11:34:28 +00:00

70 lines
1.2 KiB
Plaintext

;; lib/minikanren/tests/repeato-concato.sx — repeat element n times +
;; concatenate a list of lists.
(define
mk-nat
(fn (n) (if (= n 0) :z (list :s (mk-nat (- n 1))))))
;; --- repeato ---
(mk-test
"repeato-zero"
(run* q (repeato :a (mk-nat 0) q))
(list (list)))
(mk-test
"repeato-one"
(run* q (repeato :a (mk-nat 1) q))
(list (list :a)))
(mk-test
"repeato-three"
(run* q (repeato :a (mk-nat 3) q))
(list (list :a :a :a)))
(mk-test
"repeato-numeric"
(run* q (repeato 7 (mk-nat 4) q))
(list (list 7 7 7 7)))
(mk-test
"repeato-recover-count"
(run* q (repeato :x q (list :x :x :x :x)))
(list (mk-nat 4)))
;; --- concato ---
(mk-test "concato-empty" (run* q (concato (list) q)) (list (list)))
(mk-test
"concato-single"
(run* q (concato (list (list 1 2 3)) q))
(list (list 1 2 3)))
(mk-test
"concato-multi"
(run*
q
(concato
(list
(list 1 2)
(list 3)
(list 4 5 6))
q))
(list
(list 1 2 3 4 5 6)))
(mk-test
"concato-all-empty"
(run* q (concato (list (list) (list) (list)) q))
(list (list)))
(mk-test
"concato-mixed-empty"
(run*
q
(concato
(list (list 1) (list) (list 2 3))
q))
(list (list 1 2 3)))
(mk-tests-run!)