This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-09-13
Channels
- # announcements (2)
- # babashka (2)
- # beginners (112)
- # calva (29)
- # cider (33)
- # clj-kondo (41)
- # cljdoc (10)
- # cljs-dev (2)
- # clojure (72)
- # clojure-berlin (3)
- # clojure-europe (10)
- # clojure-italy (6)
- # clojure-nl (15)
- # clojure-spec (5)
- # clojure-uk (40)
- # clojurescript (1)
- # clr (6)
- # community-development (6)
- # core-async (21)
- # cursive (42)
- # datascript (12)
- # duct (6)
- # flambo (1)
- # fulcro (50)
- # jobs (1)
- # leiningen (3)
- # off-topic (16)
- # re-frame (6)
- # reagent (23)
- # reitit (7)
- # ring-swagger (14)
- # shadow-cljs (35)
- # tools-deps (39)
- # vim (12)
how would one go about finding out simply if there were any matches for an arbitrary set of clauses in a find
? I'm not interested in binding any solutions to the clause, just the fact that there was actually at least one solution. I'm trying to build a generic "datascript predicate" where a user will pass in their clauses and I'll return true
if there is a solution. For example, if the user supplied clause were the [(?get-in...
bit of this example:
(ds/q '{:find [?answer]
:in [?context ?get-in]
:where [[(?get-in ?context [:foo :tags :quux])]
[(ground true) ?answer]]}
{:foo {:tags #{:bar :baz}}} #(get-in %1 %2))
I would expect the and
nature of the full set of clauses to bind ?answer
to the empty set, instead I get #{[true]}
I'm confused, that's not the normal datalog syntax..?
you're using standard datascript @mike795?
(ds/q '[:find (seq ?answer)
:in ?context ?get-in
:where [[(?get-in ?context [:foo :tags :quux])]
[(ground true) ?answer]]]
{:foo {:tags #{:bar :baz}}} #(get-in %1 %2))
would be the conventional equivalentalso I think this is maybe kind of what you're looking for?
(ds/q '[:find ?answer
:in ?context ?get-in
:where
[(?get-in ?context [:foo :tags :quux]) ?answer]]
{:foo {:tags #{:bar :baz}}} #(get-in %1 %2))
that binds to the empty set
@mike795 in #datomic i do [(.invoke ?get-int ?context ...)]
but not sure if #datascript behavior like this
@goomba it's the "map datalog syntax". Map syntax is easier to "machines" write/read datalog. "array" syntax is easier to humans write/read
fascinating, I've never seen that before, will have to look into it
As @U2J4FRT2T suggests, it's helpful when you're dynamically/programatically constructing queries (e.g. a sophisticated search UI). Modifying clauses in a list is hard to do programatically, but quite straight forward when organized in a map.