core-logic 2018-09-14

agreed. I think the confusion is also perhaps because conj in microkanren is not clojure’s conj. It’s conj^2 which is conjunctive (`and`)… likewise disj in microkanren is disjuntive i.e. or. Not sure if core.logic ports these functions directly either, as they’re part of microkanren… and perhaps not minikanren… would need to look.

I don’t have the papers in front of me though so could also be wrong…

i know -o is a relation, how those lazy streams and conj/disj are implremented key in making sure appendo doesnt recurse forever and blow the stack

thats not true, the fact that appendo does case analysis and only one of the cases can be true at a time, and induction on the first argument (the first argument is smaller on every recursvie call) is what guarantees termination

ah, the blowing the stack

that is because in your implementation you are doing the recursive call to appendo when appendo is called, not as the logic program is running

doing that switch is tricky in a language without macros

in my go implementation I had a special goal constructor for making recursive calls to make that work

there's something key with that which im messing up

it doesn't have to do with the stream implementation

it has to do with goal construction, which without macros, you can't delay the recursive call until you know if you have to do it

so if or or disj is a regular function, all of its arguments must be evaluated before it is called, and if one of those is a recursive call, boom

yeah, it has to delay the goal somehow

so my Call goal constructor in go would look something like (fn [goal & args] (fn [package] ((apply goal args) package))) in clojure