VocabularycombinatorsInputs and outputs| assoc | a sequence of quotation pairs and an optional quotation |
Word descriptionCalls the second quotation in the first pair whose first quotation yields a true value. A single quotation will always yield a true value.
The following two phrases are equivalent:
{ { [ X ] [ Y ] } { [ Z ] [ T ] } } cond
X [ Y ] [ Z [ T ] [ no-cond ] if ] if
ErrorsThrows a
no-cond error if none of the test quotations yield a true value.
ExamplesUSING: combinators io kernel math ;
0 {
{ [ dup 0 > ] [ drop "positive" ] }
{ [ dup 0 < ] [ drop "negative" ] }
[ drop "zero" ]
} cond print
zero
Definition