From 69d4f1c761291d2c33c4b22454877402465b2c48 Mon Sep 17 00:00:00 2001 From: "Thomas Bushnell, BSG" Date: Sun, 4 Dec 2005 20:03:34 -0800 Subject: Import Debian changes 3a2-3 slib (3a2-3) unstable; urgency=low * Brought all source files up-to-date with upstream CVS. Repeat changes from version 3a2-1 in Makefile. --- srfi-61.scm | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 srfi-61.scm (limited to 'srfi-61.scm') diff --git a/srfi-61.scm b/srfi-61.scm new file mode 100644 index 0000000..015320b --- /dev/null +++ b/srfi-61.scm @@ -0,0 +1,49 @@ +;;; "srfi-61.scm" -- A more general cond clause -*- Scheme -*- + +;;; Public domain +;;; Author: Taylor Campbell +;;; URL:http://srfi.schemers.org/srfi-61/srfi-61.html + +;@ +(define-syntax cond + (syntax-rules (=> else) + + ((cond (else else1 else2 ...)) + ;; The (IF #T (BEGIN ...)) wrapper ensures that there may be no + ;; internal definitions in the body of the clause. R5RS mandates + ;; this in text (by referring to each subform of the clauses as + ;; ) but not in its reference implementation of COND, + ;; which just expands to (BEGIN ...) with no (IF #T ...) wrapper. + (if #t (begin else1 else2 ...))) + + ((cond (test => receiver) more-clause ...) + (let ((T test)) + (cond/maybe-more T + (receiver T) + more-clause ...))) + + ((cond (generator guard => receiver) more-clause ...) + (call-with-values (lambda () generator) + (lambda T + (cond/maybe-more (apply guard T) + (apply receiver T) + more-clause ...)))) + + ((cond (test) more-clause ...) + (let ((T test)) + (cond/maybe-more T T more-clause ...))) + + ((cond (test body1 body2 ...) more-clause ...) + (cond/maybe-more test + (begin body1 body2 ...) + more-clause ...)))) + +(define-syntax cond/maybe-more + (syntax-rules () + ((cond/maybe-more test consequent) + (if test + consequent)) + ((cond/maybe-more test consequent clause ...) + (if test + consequent + (cond clause ...))))) -- cgit v1.2.3