match-cond ( assoc -- quot )
Pattern matching

Prev:match ( value1 value2 -- bindings )
Next:match-replace ( object pattern1 pattern2 -- result )


Vocabulary
match

Inputs
assoca sequence of pairs


Outputs
None

Word description
Calls the second quotation in the first pair whose first sequence yields a successful match against the top of the stack. The second quotation, when called, has the hashtable returned from the match call bound as the top namespace so the match variables can be used to retrieve the values. A single quotation will always yield a true value. To have a fallthrough match clause use the _ match variable.

Errors
Throws a no-match-cond error if none of the test quotations yield a true value.

Examples
USE: match MATCH-VARS: ?value ; { increment 346126 } { { { increment ?value } [ ?value do-something ] } { { decrement ?value } [ ?value do-something-else ] } { _ [ no-match-found ] } } match-cond


See also
match, MATCH-VARS:, replace-patterns, match-replace

Definition