Liking cljdoc? Tell your friends :D
Clojure only.

sg.flybot.pullable

Pull from data structure by using pattern.

Pattern is a DSL in clojure data structure, specify how to extract information from data.

Pull from data structure by using pattern.

Pattern is a DSL in clojure data structure, specify how to extract
information from data.
raw docstring

queryclj

(query pattern)

Returns a compiled query from pattern. A query can be used to extract information from data.

A pattern is a clojure data structure, in most cases, a pattern looks like the data which it queries, for example, to query data {:a {:b {:c 5}} :d {:e 2}} to extract :c, :e, you might use a pattern '{:a {:b {:c ?c}} :d {:e ?e}}. By marking the information you are interested in by logic variable like ?c, ?e, or by anonymous variable ?, you can get informatioon from the potentially massive data.

  • Map pattern: {...}, mimic the shape of the map to be queried

  • Filter pattern: If you specified a concrete value for a given key in a map, it works like a filter, i.e., pattern {:a ? :b 1} will return an empty map on data {:a 1 :b 2}. If you use same logical variabl in multiple places of a pattern, it has to be the same value, so if we can not satisfy this, the matching fails. i.e., pattern '{:a ?x :b ?x} returns an empty map on data {:a 2 :b 3}.

  • Options: by enclosing a key in map pattern with a list (), and optional pairs of options, you can process value after a match or miss. i.e., pattern {(:a :not-found ::ok) ?} on data {:b 5} having a matching result of {:a ::ok}. Various options supported, and can be defined by multimethod of core/apply-post.

  • Sequence pattern: For sequence of maps, using [] to enclose it. Sequence pattern can have an optional variable and options. i.e., pattern '[{:a ?} ?] on [{:a 1} {:a 3} {}] has a matching result of [{:a 1} {:a 3} {}].

Returns a compiled query from `pattern`. A query can be used to extract information
from data.

A pattern is a clojure data structure, in most cases, a pattern looks like the data
which it queries, for example, to query data `{:a {:b {:c 5}} :d {:e 2}}` to extract
`:c`, `:e`, you might use a pattern `'{:a {:b {:c ?c}} :d {:e ?e}}`. By marking the
information you are interested in by logic variable like `?c`, `?e`, or by anonymous
variable `?`, you can get informatioon from the potentially massive data.

  - Map pattern: `{...}`, mimic the shape of the map to be queried

  - Filter pattern: If you specified a concrete value for a given key in a map, it works
    like a filter, i.e., pattern `{:a ? :b 1}` will return an empty map on data `{:a 1 :b 2}`.
    If you use same logical variabl in multiple places of a pattern, it has to be the
    same value, so if we can not satisfy this, the matching fails. i.e., 
    pattern `'{:a ?x :b ?x}` returns an empty map on data `{:a 2 :b 3}`.

  - Options: by enclosing a key in map pattern with a list `()`, and optional pairs of
    options, you can process value after a match or miss. i.e., pattern
    `{(:a :not-found ::ok) ?}` on data `{:b 5}` having a matching result of `{:a ::ok}`.
    Various options supported, and can be defined by multimethod of `core/apply-post`.

  - Sequence pattern: For sequence of maps, using `[]` to enclose it. Sequence pattern
    can have an optional variable and options. i.e., pattern 
    `'[{:a ?} ?]` on `[{:a 1} {:a 3} {}]` has a matching result of
    `[{:a 1} {:a 3} {}]`. 
sourceraw docstring

runclj

(run query-or-pattern data)

Given data, compile pattern if it has not been, run it, try to match with data. Returns a vector of matching result (same structure as data) and a map of logical variable bindings.

Given `data`, compile `pattern` if it has not been, run it, try to match with `data`.
Returns a vector of matching result (same structure as data) and a map of logical
variable bindings.
sourceraw docstring

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

× close