cond-case ( assoc -- quot )


Vocabulary
combinators.extras

Inputs
assoca sequence of quotation pairs and an optional quotation


Outputs
None

Word description
Similar to case, this evaluates an obj according to the first quotation in each pair. If any quotation returns true, calls the second quotation without obj on the stack.

If there is no quotation that returns true, the default case is taken. If the last element of assoc is a quotation, the quotation is called with obj on the stack. Otherwise, a no-cond error is raised.

Examples
USING: combinators.extras io kernel math ; 0 { { [ 0 > ] [ "positive" ] } { [ 0 < ] [ "negative" ] } [ drop "zero" ] } cond-case print
zero


Definition