PatternMatchResult(R, S)¶
patmatch1.spad line 1 [edit on github]
R: SetCategory
S: SetCategory
A PatternMatchResult is an object internally returned by the pattern matcher; It is either a failed match, or a list of matches of the form (var, expr) meaning that the variable var matches the expression expr.
- addMatch: (Pattern R, S, %) -> %
addMatch(var, expr, r)adds the match (var,expr) inr, provided thatexprsatisfies the predicates attached tovar, and thatvaris not matched to another expression already.
- addMatchRestricted: (Pattern R, S, %, S) -> %
addMatchRestricted(var, expr, r, val)adds the match (var,expr) inr, provided thatexprsatisfies the predicates attached tovar, thatvaris not matched to another expression already, and that eithervaris an optional pattern variable or thatexpris not equal to val (usually an identity).
- coerce: % -> OutputForm
from CoercibleTo OutputForm
- construct: List Record(key: Symbol, entry: S) -> %
construct([v1, e1], ..., [vn, en])returns the match result containing the matches (v1,e1), …, (vn, en).
- destruct: % -> List Record(key: Symbol, entry: S)
destruct(r)returns the list of matches (var, expr) inr. Error: ifris a failed match.
- failed?: % -> Boolean
failed?(r)tests ifris a failed match.
- failed: () -> %
failed()returns a failed match.
- getMatch: (Pattern R, %) -> Union(S, failed)
getMatch(var, r)returns the expression thatvarmatches in the resultr, and “failed” ifvaris not matched inr.
- insertMatch: (Pattern R, S, %) -> %
insertMatch(var, expr, r)adds the match (var,expr) inr, without checking predicates or previous matches forvar.
- latex: % -> String
from SetCategory
- new: () -> %
new()returns a new empty match result.
- satisfy?: (%, Pattern R) -> Union(Boolean, failed)
satisfy?(r, p)returnstrueif the matches satisfy the top-level predicate ofp,falseif they don't, and “failed” if not enough variables ofpare matched inrto decide.
- union: (%, %) -> %
union(a, b)makes the set-union of two match results.