match ( value1 value2 -- bindings )
Pattern matching

Prev:MATCH-VARS:
Next:match-cond ( assoc -- quot )


Vocabulary
match

Inputs
value1an object
value2an object


Outputs
bindingsan assoc


Word description
Pattern match value1 against value2. These values can be any Factor value, including sequences and tuples. The values can contain pattern variables, which are symbols that begin with '?'. The result is a hashtable of the bindings, mapping the pattern variables from one sequence to the equivalent value in the other sequence. The _ symbol can be used to ignore the value at that point in the pattern for the match.

Examples
USE: match MATCH-VARS: ?a ?b ; { ?a { 2 ?b } 5 } { 1 { 2 3 } _ } match .
H{ { ?a 1 } { ?b 3 } }


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

Definition


: match ( value1 value2 -- bindings )
[ (match) ] H{ } make and ;