#[unsafe(no_mangle)]pub unsafe extern "C" fn patch_seq_cond(stack: Stack) -> StackExpand description
Multi-way conditional combinator
Takes N predicate/body quotation pairs from the stack, plus a value to test. Tries each predicate in order (last to first on stack). When a predicate returns non-zero, executes its corresponding body and returns.
Stack effect: ( value [pred1] [body1] [pred2] [body2] … [predN] [bodyN] count – result )
Each predicate quotation has effect: ( value – value bool ) Each body quotation has effect: ( value – result )
Example:
: route ( request -- response )
[ dup "GET /" = ] [ drop "Hello" ]
[ dup "/api" starts-with ] [ get-users ]
[ drop 1 ] [ drop "Not Found" ]
3 cond ;§Safety
- Stack must have at least (2*count + 2) values
- All predicate/body values must be Quotations
- Predicates must return Int (0 or non-zero)