This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-05-17
Channels
- # aws (3)
- # beginners (104)
- # boot (11)
- # calva (3)
- # clj-kondo (1)
- # cljdoc (6)
- # cljs-dev (23)
- # cljsrn (1)
- # clojure (144)
- # clojure-dev (54)
- # clojure-europe (6)
- # clojure-italy (2)
- # clojure-nl (26)
- # clojure-spec (6)
- # clojure-sweden (1)
- # clojure-uk (13)
- # clojurescript (38)
- # core-async (9)
- # cursive (14)
- # data-science (3)
- # datascript (22)
- # datomic (17)
- # figwheel (1)
- # fulcro (4)
- # graphql (6)
- # hoplon (59)
- # jackdaw (2)
- # jobs (6)
- # jobs-discuss (44)
- # juxt (14)
- # leiningen (1)
- # luminus (3)
- # nrepl (3)
- # off-topic (12)
- # re-frame (24)
- # reagent (7)
- # reitit (7)
- # rewrite-clj (1)
- # schema (1)
- # shadow-cljs (37)
- # spacemacs (4)
- # sql (25)
- # testing (12)
- # tools-deps (11)
- # utah-clojurians (1)
In this rule:
[(subproject-or-self ?e1 ?e2)
[?e1]
(subproject ?e1 ?e2)]]
What does [?e1]
do? I’ve yet to encounter that syntax in my limited experimentations with Datascript.@d4hines The intention was that subproject-or-self
evaluates to either ?e1 or subprojects thereof.
@urzds What does that [ ]
syntax do?
Does it just fill in attribute and value with blanks?
@d4hines I believe so. I just took the recursive example from the datascript readme and adapted it to my needs as appeared logical to me. Lucky me: It worked. 😉
I think rules exist to create relations automatically? So [?e1] is a relation. The one with AVT=blank. That's how I understand it, without being an expert.
That’s definitely how I would read that, but what does [?e1 _ _]
buy you? That there’s an entity with that id? isn’t that implicit in the query?
Well, I can tell you that (subproject ?e ?existing-project)
finds you all subprojects ?e, but not including ?existing-project.
So I added another rule that would also match ?existing-project in addition to the subprojects the other rule found. I kept subproject
and subproject-or-self
separate in order to prevent funny stuff from happening (infinite recursions?), without having a specific reason.
I guess I’m not convinced that this query:
[(subproject-or-self ?e1 ?e2)
[?e2]
(subproject ?e1 ?e2)]]
could ever return a different set than this query:
[(subproject-or-self ?e1 ?e2)
(subproject ?e1 ?e2)]]
Or indeed, that the addition of any form with the pattern [?e]
could ever change any result set.And I’m interested because if I’m wrong, I need to reevaluate how I think queries…evaluate.
How else would you answer my question from yesterday? How to make ?project the union of ?top-level-project and some list of [?subproject]s?
I would have tried
[(or [?project :unique-id ?top-level-project-id] (subproject ?project ?top-level-project-id)]
But I’m new at this - that’s just a hunch.
You’ve gotta just try this at the REPL.
I think I got error messages regarding unbound variables when I did it with or
. So I tried or-join
, but that resulted in what I posted above.
Gotcha. Reading, the docs on or-join
, that makes sense now. This has been a helpful excursion - thanks for sharing it with us!
It’s probably just so much spam for the ol’ timers, but I know I learned something 😛