Liking cljdoc? Tell your friends :D

code.query.match.pattern


pattern-fnclj

(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

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
raw docstring

pattern-matchesclj

(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 matches for a given template
((pattern-matches ()) ())
=> '(())

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

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

pattern-single-fnclj

(pattern-single-fn pattern)

creates a function based on template

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

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

creates a function based on template

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

((pattern-single-fn '(a)) '(b))
=> false
raw docstring

transform-patternclj

(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 #'number?} #'string?]]) => [[:code {:a #'clojure.core/number?} #'clojure.core/string?]]

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 #'number?} #'string?]])
=> [[:code {:a #'clojure.core/number?}
     #'clojure.core/string?]]
raw docstring

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

× close