This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-09-14
Channels
- # 100-days-of-code (4)
- # announcements (1)
- # beginners (63)
- # boot (22)
- # braveandtrue (104)
- # calva (3)
- # cider (12)
- # cljs-dev (53)
- # cljsjs (3)
- # cljsrn (1)
- # clojure (180)
- # clojure-dev (14)
- # clojure-italy (4)
- # clojure-nl (11)
- # clojure-spec (15)
- # clojure-uk (60)
- # clojure-ukraine (1)
- # clojurescript (118)
- # clojutre (3)
- # core-async (12)
- # core-logic (17)
- # cursive (19)
- # datomic (45)
- # devcards (4)
- # emacs (7)
- # figwheel-main (218)
- # fulcro (27)
- # funcool (3)
- # graphql (1)
- # jobs (4)
- # leiningen (57)
- # off-topic (71)
- # pedestal (2)
- # portkey (17)
- # re-frame (5)
- # reitit (4)
- # remote-jobs (2)
- # ring (11)
- # rum (2)
- # shadow-cljs (14)
- # specter (11)
- # sql (34)
- # tools-deps (23)
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
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
in my go implementation I had a special goal constructor for making recursive calls to make that work
https://github.com/hiredman/gologic/blob/master/gologic.go#L533-L550 https://github.com/hiredman/gologic/blob/master/gologic_test.go#L110-L116
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
so my Call goal constructor in go would look something like (fn [goal & args] (fn [package] ((apply goal args) package)))
in clojure
which has a similar structure to what conde in core.logic expands to https://github.com/clojure/core.logic/blob/master/src/main/clojure/clojure/core/logic.clj#L1175-L1183