switch ( quot-alist -- quot )
Invertible quotations

Prev:matches? ( quot -- quot' )


Vocabulary
inverse

Inputs
quot-alistan alist from inverse quots to quots


Outputs
None

Word description
The equivalent of a case expression in a programming language with buitlin pattern matchining. It attempts to match the stack with each of the patterns, in order, by treating them as inverse quotations. Failure causes the next pattern to be tested.
TUPLE: cons car cdr ; C: <cons> cons : sum ( list -- sum ) { { [ <cons> ] [ sum + ] } { [ f ] [ 0 ] } } switch ;


See also
undo

Definition

MACRO: switch ( quot-alist -- quot ) [switch] ;