Files
rose-ash/lib/minikanren/tests/foldr-o.sx
giles 3842496f3b
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Has been cancelled
mk: foldr-o — relational right fold
Takes a 3-arg combiner relation, a list, and an initial accumulator,
produces the right-fold result. (rel a tail-result result) combines
the head with the recursive result.

Examples:
  (foldr-o appendo (list (list 1 2) (list 3) (list 4 5)) (list) q)
    -> ((1 2 3 4 5))                ; flatten

  (foldr-o conso (list 1 2 3) (list) q)
    -> ((1 2 3))                    ; rebuild list

4 new tests, 505/505 cumulative.
2026-05-08 12:21:42 +00:00

39 lines
629 B
Plaintext

;; lib/minikanren/tests/foldr-o.sx — relational right fold.
(mk-test
"foldr-o-empty"
(run* q (foldr-o conso (list) (list 99) q))
(list (list 99)))
(mk-test
"foldr-o-conso-rebuilds-list"
(run* q (foldr-o conso (list 1 2 3) (list) q))
(list (list 1 2 3)))
(mk-test
"foldr-o-appendo-flattens"
(run*
q
(foldr-o
appendo
(list
(list 1 2)
(list 3)
(list 4 5))
(list)
q))
(list (list 1 2 3 4 5)))
(mk-test
"foldr-o-with-acc-init"
(run*
q
(foldr-o
conso
(list 1 2)
(list 9 9)
q))
(list (list 1 2 9 9)))
(mk-tests-run!)