code.query.match.pattern

pattern-fn

added in 3.0

(pattern-fn template)

make sure that functions are working properly ((pattern-fn vector?) []) => true

((pattern-fn #’vector?) []) => true

((pattern-fn ’^:% vector?) []) => true

((pattern-fn ’^:% symbol?) []) => false

((pattern-fn ’^:% vector?) ) => true

((pattern-fn :code map? string?) :code {} "hello") => true

((pattern-fn :code {:a number?} string?) :code {:a 1} "hello") => true

((pattern-fn :code {:a {:b number?}} string?) :code {:a {:b 1}} "hello") => true

pattern-matches

added in 3.0

(pattern-matches template)

pattern matches for a given template ((pattern-matches ()) ()) => ’(())

((pattern-matches []) ()) => ()

((pattern-matches ’(^:% symbol? ^:? (+ 1 _ ^:? _))) ’(+ (+ 1 2 3))) => ’((^{:% true} symbol? ^{:? 0} (+ 1 _ ^{:? 1} _)))

pattern-single-fn

added in 3.0

(pattern-single-fn pattern)

creates a function based on template

((pattern-single-fn ’(a)) ’(a)) => true

((pattern-single-fn ’(a)) ’(b)) => false

transform-pattern

added in 3.0

(transform-pattern pattern)

converts an input into an actual matchable pattern

(transform-pattern ^:& #{:a :b}) => (all match/actual-pattern? #(= (:expression %) #{:a :b}))

(transform-pattern ’^:% (symbol “_”)) => (all match/eval-pattern? #(= (:expression %) ’(symbol “_”)))

(transform-pattern #{:a :b}) => #{:a :b}

(transform-pattern :a :b) => :a :b

(transform-pattern :code {:a ) => :code {:a