This extension provides several variations on the standard cond and case syntax and the chicken-specific switch, and some useful functions. It implements SRFI-61 (cond with guards) and SRFI-87 (case with cond-like => syntax).
The extension relies on syntax-case macros.
Generalized member that returns the first tail of LIST with a car such that (EQUAL?? foo VALUE) is true.
case implemented using SRFI-87 extensions, which add an optional => keyword that acts like cond's: The matching object is pased to PROCEDURE, which is a one-argument function. In all other cases, it behaves just like the traditional case.
A generalised version of SRFI-87 case that takes a user-defined equality predicate that takes two arguments.
cond implemented with the SRFI-61 syntax extension. (TEST GUARD => PROC) first evaluates TEST. If true, its return value is passed to GUARD. If that also returns true, the original return values of TEST are passed to PROC. In all other cases, it behaves just like the traditional cond.
switch implemented with the same SRFI-87 => syntax as case.
A generalized version of switch that takes a user-defined equality predicate and implements SRFI-87 style => syntax.
(require-extension extended-cond) (case* string=? "foo" (("foo" "bar" "baz") => (lambda (what) (format "Matched ~A!~N" what))) (else (print "Didn't match!"))) (define foo '((do-this . #t) (do-that . #f))) (cond ((assq 'do-that foo) cdr => (lambda (pair) (format "Will ~A~N" (car pair)))) (else (format "Won't do anything.~N")))
Public domain.