This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-01-26
Channels
- # announcements (5)
- # architecture (79)
- # babashka (48)
- # beginners (148)
- # calva (57)
- # cider (31)
- # clara (2)
- # clj-kondo (4)
- # cljs-dev (6)
- # cljsrn (1)
- # clojure (10)
- # clojure-australia (4)
- # clojure-dev (5)
- # clojure-europe (13)
- # clojure-france (1)
- # clojure-nl (6)
- # clojure-provo (4)
- # clojure-uk (51)
- # clojurescript (38)
- # conjure (20)
- # core-logic (18)
- # cursive (28)
- # datomic (12)
- # duct (2)
- # emacs (16)
- # figwheel-main (3)
- # fulcro (43)
- # honeysql (17)
- # hoplon (3)
- # jobs (1)
- # meander (4)
- # mount (5)
- # off-topic (32)
- # pathom (6)
- # pedestal (5)
- # re-frame (1)
- # reagent (2)
- # reveal (8)
- # shadow-cljs (209)
- # spacemacs (5)
- # tools-deps (37)
- # xtdb (18)
In https://github.com/clojure/core.logic/wiki/Differences-from-The-Reasoned-Schemer the pair? predicate is defined, but this will make the following true
(pair? '(a b c)) ;-> true
(pair? (lcons '(1 2) \s)) ;-> true
Isn't a pair (a . b) or (a b), not a list of more than 2 items?in traditional lisps, lists are exposed linked lists of cells, each cell is like a 2 element array, one of the elements is called the car and one is called the cdr. those cells are what are pairs, that pair? returns true on in scheme
so (a . b) is a pair with the car a and the cdr b. (a b) is a pair where the car is a, and the cdr is (b), and (b) is a pair where the car is b and the cdr is nil
https://people.csail.mit.edu/jaffer/r5rs_8.html#IDX319 is some documentation on the scheme function
Ah yes, I know about that. It's a cell, right?
yes, and that all applies to scheme, clojure is different, clojure is primarily concerned with seqs (clojure lists are seqs) which don't actually expose the cells that make them up
but having cons cells and improper lists (cells where the cdr is not a pair or nil) is useful in minikanren because you can represent a list where you haven't figured out what the rest of the list yet (the cdr is a logic var)
I understand, but that makes pair a little odd in Clojure.
pair doesn't really exist in the wider world of clojure, but exists in core.logic because The Reasoned Schemer is an important source of documentation for it, and examples in TRS need it
Yeah when I had a go at implementing microkanren, I found probably half the code of the complete implementation was just implementing scheme like linked lists in clojure.
I saw another approach at https://mullr.github.io/micrologic/literate.html Another approach could also be something which implements iseq then you cons on it, no?
IIRC this is more or less what I ended up doing https://github.com/bodil/microkanrens/blob/66b5ef7e1f1bf3ce7858a2f6e427ad750a3e9a45/mk.clj#L1-L48 https://www.youtube.com/watch?v=2e8VFSSNORg
well, really you'd need something like it even without the TRS to reason about lists, but the reason it is the way it is is because of TRS
Thanks