Liking cljdoc? Tell your friends :D

pattern.match

Implementation of a pattern matching system inspired by Gerald Jay Sussman's lecture notes for MIT 6.945. See pattern.rule for a higher-level API.

pattern.match is spiritually similar to Alexey Radul's Rules library for Scheme.

Implementation of a pattern matching system inspired by [Gerald Jay Sussman's
lecture notes for MIT
6.945](http://groups.csail.mit.edu/mac/users/gjs/6.945/).
See [[pattern.rule]] for a higher-level API.

[[pattern.match]] is spiritually similar to Alexey
Radul's [Rules](https://github.com/axch/rules) library for Scheme.
raw docstring

matchclj/s

(match matcher data)
(match matcher data predicate)

Convenience function for applying a match combinator to some data.

Primes the process with an empty frame and supplies a continuation which will return the pattern bindings if the match is successful, nil otherwise. If predicate is supplied, then the resulting frame of a match must satisfy this predicate; otherwise we continue searching.

Convenience function for applying a match combinator to some data.

Primes the process with an empty frame and supplies a continuation
which will return the pattern bindings if the match is successful,
nil otherwise. If predicate is supplied, then the resulting frame of
a match must satisfy this predicate; otherwise we continue searching.
sourceraw docstring

match-listclj/s

(match-list matchers)
source

match-oneclj/s

(match-one thing)

Combinator which succeeds iff the head of the data is equal to thing. The frame is not modified.

Combinator which succeeds iff the head of the data is equal to
thing. The frame is not modified.
sourceraw docstring

match-segmentclj/s

(match-segment var)
source

match-varclj/s

(match-var var)
(match-var var predicate?)

If the variable is not bound in the frame, and there is more matchable data (that satisfies the optional constraint predicate), this combinator will succeed by consuming the next item in the data and produces a frame in which the data seen is bound to the pattern variable. If the variable is bound, then the value seen must match the binding to succeed (the frame is not modified in this case).

If the variable is not bound in the frame, and there is more
matchable data (that satisfies the optional constraint predicate),
this combinator will succeed by consuming the next item in the data
and produces a frame in which the data seen is bound to the pattern
variable. If the variable is bound, then the value seen must match
the binding to succeed (the frame is not modified in this case).
sourceraw docstring

pattern->matcherclj/s

(pattern->matcher pattern)

Given a pattern (which is essentially a form consisting of constants mixed with pattern variables) returns a match combinator for the pattern.

Given a pattern (which is essentially a form consisting of
constants mixed with pattern variables) returns a match combinator
for the pattern.
sourceraw docstring

segment-reference?clj/s

(segment-reference? x)

Returns true if x is a segment reference (i.e., it looks like (:?? ...)) or is a keyword ending in *, false otherwise.

Returns true if x is a segment reference (i.e., it looks like (:?? ...)) or is
a keyword ending in `*`, false otherwise.
sourceraw docstring

variableclj/s

(variable x)

Returns the variable contained in a variable or segment reference form.

Returns the variable contained in a variable or segment reference form.
sourceraw docstring

variable-reference-with-predicate?clj/s

(variable-reference-with-predicate? x)

Returns true if x is a variable reference and is also equipped with a constraint on matched values, false otherwise.

Returns true if x is a variable reference and is also equipped with a
constraint on matched values, false otherwise.
sourceraw docstring

variable-reference?clj/s

(variable-reference? x)

Returns true if x is a variable reference (i.e., it looks like (:? ...)) or is a simple keyword, false otherwise.

Returns true if x is a variable reference (i.e., it looks like (:? ...)) or is
a simple keyword, false otherwise.
sourceraw docstring

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

× close