(require 'guarded-cond-clause) or
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>)<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> ...).
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)