Liking cljdoc? Tell your friends :D

claraz.rules


defquerycljmacro

(defquery name & body)

Essentially like (def name (query ...)). Adds :query true to the metadata of the defined var. See the docstring of claraz.rules/rule for more information on how to write rules and queries using the Claraz syntax.

Essentially like (def name (query ...)). Adds :query true to the
metadata of the defined var. See the docstring of claraz.rules/rule
for more information on how to write rules and queries using the
Claraz syntax.
sourceraw docstring

defrulecljmacro

(defrule name & body)

Essentially like (def name (rule ...). Adds :rule true to the metadata of the defined var. See the docstring of claraz.rules/rule for more information on how to write rules and queries using the Claraz syntax.

Essentially like (def name (rule ...). Adds :rule true to the metadata
of the defined var. See the docstring of claraz.rules/rule for more
information on how to write rules and queries using the Claraz
syntax.
sourceraw docstring

fact?clj

(fact? x)
source

querycljmacro

(query name & body)

Create a Clara query using Claraz syntax. See the docstring of claraz.rules/rule.

Create a Clara query using Claraz syntax. See the docstring of
claraz.rules/rule.
sourceraw docstring

query*clj

(query* name & body)

Function version of claraz.rules/query.

Function version of claraz.rules/query.
sourceraw docstring

query+clj

(query+ session query-or-kw & args)

Like clara.rules/query but with two modifications.

First, query-or-kw can be a keyword naming a query created by claraz.rules/query (or query*) and can be used in case the rule is not defined in a namespace. The keyword should just be a keyword version of the symbol used in the claraz.rules/query call.

Seconds, args can (but doesn't have to) be passed without the keywords, as positional args, e.g. (query+ session some-query 1 2) instead of (query+ session some-query :?x 1 :?y 2).

Like clara.rules/query but with two modifications.

First, query-or-kw can be a keyword naming a query created by
claraz.rules/query (or query*) and can be used in case the rule is
not defined in a namespace. The keyword should just be a keyword
version of the symbol used in the claraz.rules/query call.

Seconds, args can (but doesn't have to) be passed without the
keywords, as positional args, e.g. (query+ session some-query 1 2)
instead of (query+ session some-query :?x 1 :?y 2).
sourceraw docstring

rulecljmacro

(rule name & body)

Create a Clara rule using Claraz syntax. Returns the rule, and does not define it in the current namespace.

Arguments: [name docstring? salience? & body]. Salience is written simply :salience n, without a wrapping map.

Claraz syntax is similar to Clara syntax, the only difference is that the <- and :from are not used. Instead of :from Claraz uses a vector. These example should be all you need.

Clara: [?f <- FactType [destructuring] constraints] Claraz: [?f FactType [destructuring] constraints]

Clara: [?f <- acc :from [FactType [destructuring] constraints]] Claraz: [?f [acc FactType] [destructuring] constraints]].

The binding symbol (?f above), destructuring vector, and constraints are all optional, just like in Clara.

:not, :and, :or, :exists, and :test conditions are possible, just like in Clara.

Claraz also makes it possible to use symbols bound by destructuring in any condition on the left-hand side in the right hand side, even if they don't start with a ?. Example: [Person [{:keys [name] :as p}]] => (insert! (->Fact name p))

Reusing symbols in destructurings in later conditions shadow earlier ones.

Create a Clara rule using Claraz syntax. Returns the rule, and does not
define it in the current namespace.

Arguments: [name docstring? salience? & body]. Salience is written
simply :salience n, without a wrapping map.

Claraz syntax is similar to Clara syntax, the only difference is that
the <- and :from are not used. Instead of :from Claraz uses a vector.
These example should be all you need.

Clara:  [?f <- FactType [destructuring] constraints]
Claraz: [?f FactType [destructuring] constraints]

Clara:  [?f <- acc :from [FactType [destructuring] constraints]]
Claraz: [?f [acc FactType] [destructuring] constraints]].

The binding symbol (?f above), destructuring vector, and constraints
are all optional, just like in Clara.

:not, :and, :or, :exists, and :test conditions are possible, just
like in Clara.

Claraz also makes it possible to use symbols bound by destructuring
in any condition on the left-hand side in the right hand side, even
if they don't start with a ?. Example:
[Person [{:keys [name] :as p}]]
=>
(insert! (->Fact name p))

Reusing symbols in destructurings in later conditions shadow earlier
ones.
sourceraw docstring

rule*clj

(rule* name & body)

Function version of claraz.rules/rule.

Function version of claraz.rules/rule.
sourceraw docstring

save-queryclj

(save-query kw query)
source

translatecljmultimethod

Translate rule and query conditions from Claraz syntax to Clara syntax. destruct+syms should be a volatile with a collection in it, to which vectors of the destructure structure and binding symbol will be added for each condition that has a destructuring.

Translate rule and query conditions from Claraz syntax to Clara syntax.
destruct+syms should be a volatile with a collection in it, to which
vectors of the destructure structure and binding symbol will be added
for each condition that has a destructuring.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close