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.
(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.
(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.
(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).
(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.
(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.
(variable x)
Returns the variable contained in a variable or segment reference form.
Returns the variable contained in a variable or segment reference form.
(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.
(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.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close