(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(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} _)))(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
(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?]]cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |