define (unhygienic) let macro
This commit is contained in:
parent
98a41314fe
commit
b10ef13ca0
|
@ -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))))
|
||||||
|
|
Loading…
Reference in New Issue