Skip to content

Commit cf9671d

Browse files
committed
Implement many_non_ans
1 parent d8b7666 commit cf9671d

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

spec/micro_kanren/core_spec.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,9 @@
151151
ast_to_s(res).must_equal '((nil _.0 _.0) ((_.0) _.1 (_.0 . _.1)))'
152152
end
153153
end
154+
155+
it "#many non-ans" do
156+
res = take(1, many_non_ans.call(empty_state))
157+
ast_to_s(res).must_equal '(((([0] . 3)) . 1))'
158+
end
154159
end

spec/test_programs.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,29 @@ def ground_appendo2
7272
appendo2.call(cons(:a, nil), cons(:b, nil), cons(:a, cons(:b, nil)))
7373
end
7474

75+
def relo
76+
-> (x) {
77+
call_fresh(-> (x1) {
78+
call_fresh(-> (x2) {
79+
conj(
80+
eq(x, cons(x1, x2)),
81+
disj(
82+
eq(x1, x2),
83+
-> (s_c) {
84+
-> { relo.call(x).call(s_c) }
85+
}
86+
)
87+
)
88+
})
89+
})
90+
}
91+
end
92+
93+
def many_non_ans
94+
call_fresh(-> (x) {
95+
disj(
96+
relo.call(cons(5, 6)),
97+
eq(x, 3))})
98+
end
7599
end
76100
end

0 commit comments

Comments
 (0)