From b10ef13ca0d07cb090b0c7c9fb39bb18af8998db Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Wed, 30 Oct 2013 17:09:51 +0900 Subject: [PATCH] define (unhygienic) let macro --- piclib/built-in.scm | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/piclib/built-in.scm b/piclib/built-in.scm index 7533843e..9ed69a32 100644 --- a/piclib/built-in.scm +++ b/piclib/built-in.scm @@ -1,3 +1,7 @@ +; Although looking like a magic, it works nice. +(define (car x) (car x)) +(define (cdr x) (cdr x)) + (define (zero? n) (= n 0)) @@ -72,3 +76,13 @@ obj (cons (car obj) (list-copy (cdr obj))))) + +(define (map f list) + (if (null? list) + '() + (cons (f (car list)) + (map f (cdr list))))) + +(define-macro let + (lambda (bindings . body) + (cons (cons 'lambda (cons (map car bindings) body)) (map cadr bindings))))