From 8d1bfc026b8a4ff60a90f63c99b067c9e994c95f Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Thu, 14 Nov 2013 17:41:03 +0900 Subject: [PATCH] add do macro --- piclib/built-in.scm | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/piclib/built-in.scm b/piclib/built-in.scm index c916e972..9eb4d8a4 100644 --- a/piclib/built-in.scm +++ b/piclib/built-in.scm @@ -259,6 +259,19 @@ (apply consumer (cdr res)) (consumer res)))) +(define-macro (do bindings finish . body) + `(let loop ,(map (lambda (x) + (list (car x) (cadr x))) + bindings) + (if ,(car finish) + (begin ,@(cdr finish)) + (begin ,@body + (loop ,@(map (lambda (x) + (if (null? (cddr x)) + (car x) + (car (cddr x)))) + bindings)))))) + (define (boolean=? . objs) (define (every pred list) (if (null? list)