PatternMatchResult(R, S)

patmatch1.spad line 1 [edit on github]

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.

=: (%, %) -> Boolean

from BasicType

~=: (%, %) -> Boolean

from BasicType

addMatch: (Pattern R, S, %) -> %

addMatch(var, expr, r) adds the match (var, expr) in r, provided that expr satisfies the predicates attached to var, and that var is not matched to another expression already.

addMatchRestricted: (Pattern R, S, %, S) -> %

addMatchRestricted(var, expr, r, val) adds the match (var, expr) in r, provided that expr satisfies the predicates attached to var, that var is not matched to another expression already, and that either var is an optional pattern variable or that expr is 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) in r. Error: if r is a failed match.

failed?: % -> Boolean

failed?(r) tests if r is a failed match.

failed: () -> %

failed() returns a failed match.

getMatch: (Pattern R, %) -> Union(S, failed)

getMatch(var, r) returns the expression that var matches in the result r, and “failed” if var is not matched in r.

insertMatch: (Pattern R, S, %) -> %

insertMatch(var, expr, r) adds the match (var, expr) in r, without checking predicates or previous matches for var.

latex: % -> String

from SetCategory

new: () -> %

new() returns a new empty match result.

satisfy?: (%, Pattern R) -> Union(Boolean, failed)

satisfy?(r, p) returns true if the matches satisfy the top-level predicate of p, false if they don't, and “failed” if not enough variables of p are matched in r to decide.

union: (%, %) -> %

union(a, b) makes the set-union of two match results.

BasicType

CoercibleTo OutputForm

SetCategory