match ( value1 value2 -- bindings ) - Factor Documentation

match ( value1 value2 -- bindings )
Pattern matching

Prev: MATCH-VARS:


Vocabulary
match

Inputs
value1 an object
value2 an object


Outputs
bindings an 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
USING: kernel make ;

IN: match

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

AltStyle によって変換されたページ (->オリジナル) /