define (unhygienic) let macro

This commit is contained in:
Yuichi Nishiwaki 2013-10-30 17:09:51 +09:00
parent 98a41314fe
commit b10ef13ca0
1 changed files with 14 additions and 0 deletions

View File

@ -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) (define (zero? n)
(= n 0)) (= n 0))
@ -72,3 +76,13 @@
obj obj
(cons (car obj) (cons (car obj)
(list-copy (cdr 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))))