Liking cljdoc? Tell your friends :D

pattern.match.predicator


*pattern-replace*clj

Add maps used by postwalk-replace or functions that return a transformed pattern here, and they will be applied to each rule pattern with [[do-pattern-replace]] before the rule is compiled.

Add maps used by postwalk-replace or functions that return a transformed
pattern here, and they will be applied to each rule pattern with
[[do-pattern-replace]] before the rule is compiled.
raw docstring

apply-predicatorclj

(apply-predicator {:keys [abbr predicate metadata]} pattern)

apply-replacementsclj

(apply-replacements pattern replacements)

make-abbr-predicatorclj

(make-abbr-predicator abbr predicate)
(make-abbr-predicator metadata abbr predicate)

Create a function that when applied to a pattern, will add the given predicate to any short-form var that has the given abbr as the main component of its name, or if it has a prefix, that matches the prefix.

Actually just captures the data to build it. The function itself can be built on demand and this way it's more inspectable.

Example:

(make-abbr-predicator 'sym symbol?)

As applied to various patterns:

?sym          => (? sym ~symbol?)
?sym*0        => (? sym*0 ~symbol?)
??sym         => (?? sym ~symbol?)
??->sym+      => (??-> sym+ ~symbol?)
?<-$!sym:name => (?<-$! sym:name ~symbol?)

;; abbr must match, and matcher must be short-form:
?x            => ?x
(? sym)       => (? sym)

If metadata is provided, it will be attached to the matcher name, and the matcher will be marked with a $ mode character.

?sym         => (?$ ~(with-meta 'sym metadata) ~symbol)
Create a function that when applied to a pattern, will add the given
predicate to any short-form var that has the given `abbr` as the main
component of its name, or if it has a prefix, that matches the prefix.

Actually just captures the data to build it. The function itself can be built
on demand and this way it's more inspectable.

Example:

    (make-abbr-predicator 'sym symbol?)

As applied to various patterns:

    ?sym          => (? sym ~symbol?)
    ?sym*0        => (? sym*0 ~symbol?)
    ??sym         => (?? sym ~symbol?)
    ??->sym+      => (??-> sym+ ~symbol?)
    ?<-$!sym:name => (?<-$! sym:name ~symbol?)

    ;; abbr must match, and matcher must be short-form:
    ?x            => ?x
    (? sym)       => (? sym)

If `metadata` is provided, it will be attached to the matcher name, and the
matcher will be marked with a `$` mode character.

    ?sym         => (?$ ~(with-meta 'sym metadata) ~symbol)
raw docstring

match-abbrclj

(match-abbr abbr)

var-abbrclj

(var-abbr prefix n)

with-predicatescljmacro

(with-predicates pred-map & forms)

For all rules defined within this block, matchers in rules with the given abbreviations or names will automatically have the given predicate attached to them.

(with-predicates {'i int?}
  (rule '[?i ?i1 ??i*]
    ;; i, i1, and i* are guaranteed to be integers.
    (apply + i i1 i*)))
For all rules defined within this block, matchers in rules with the given abbreviations or names will
automatically have the given predicate attached to them.

    (with-predicates {'i int?}
      (rule '[?i ?i1 ??i*]
        ;; i, i1, and i* are guaranteed to be integers.
        (apply + i i1 i*)))
raw docstring

with-predicates*clj

(with-predicates* pred-map body-fn)

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

× close