Skip to content

Commit

Permalink
Add temporary fix for run in lang.hy
Browse files Browse the repository at this point in the history
  • Loading branch information
jams2 committed Nov 4, 2024
1 parent 86e0b24 commit 89fcf27
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions src/microkanren/lang.hy
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@
`(fresh ~lvars (&& #* goals)))

(defmacro run [n lvars #* goals]
`(lfor state (core.take ~n ((fresh ~lvars ~@goals)(core.empty-state)))
(core.reify (tuple (gfor i (range ~(len lvars)) (core.Var i))) state.sub)))
`(lfor
x
(core.take ~n ((fresh ~lvars ~@goals (fn [s] (core.unit (core.reify ~(tuple lvars) s.sub))))
(core.empty-state)))
x))

(defmacro run* [lvars #* goals]
(hy.macroexpand `(run -1 ~lvars ~@goals)))
Expand Down
2 changes: 1 addition & 1 deletion tests/test_lang.hy
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
(import microkanren.lang *)

(defn test-run*-eq []
(assert (= (run* [q] (== q 5) )
(assert (= (run* [q] (== q 5))
[#(5)])))

0 comments on commit 89fcf27

Please sign in to comment.