Next: Yasos, Previous: Guarded LET* special form, Up: Scheme Syntax Extension Packages [Contents][Index]
(require 'guarded-cond-clause)
or (require 'srfi-61)
http://srfi.schemers.org/srfi-61/srfi-61.html
Syntax: Each <clause> should be of the form
(<test> <expression1> …)
where <test> is any expression. Alternatively, a <clause> may be of the form
(<test> => <expression>)
The <clause> production in the formal syntax of Scheme as written by R5RS in section 7.1.3 is extended with a new option:
<clause> => (<generator> <guard> => <receiver>)
where <generator>, <guard>, & <receiver> are all <expression>s.
Clauses of this form have the following semantics: <generator> is evaluated. It may return arbitrarily many values. <Guard> is applied to an argument list containing the values in order that <generator> returned. If <guard> returns a true value for that argument list, <receiver> is applied with an equivalent argument list. If <guard> returns a false value, however, the clause is abandoned and the next one is tried.
The last <clause> may be an “else clause,” which has the form
(else <expression1> <expression2> …).
This port->char-list
procedure accepts an input port and
returns a list of all the characters it produces until the end.
(define (port->char-list port) (cond ((read-char port) char? => (lambda (c) (cons c (port->char-list port)))) (else '()))) (call-with-input-string "foo" port->char-list) ==> (#\f #\o #\o)
Next: Yasos, Previous: Guarded LET* special form, Up: Scheme Syntax Extension Packages [Contents][Index]