diff options
Diffstat (limited to 'files')
-rw-r--r-- | files/test-lambda.l | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/files/test-lambda.l b/files/test-lambda.l index d15f3ff..b29ed7b 100644 --- a/files/test-lambda.l +++ b/files/test-lambda.l @@ -54,3 +54,16 @@ (defmacro m (a) `(+ ,a 57)) (m (+ 1 2)) +(define cadr (lambda (l) (car (cdr l)))) + +(define map (lambda (fn list) + (if (nil? list) + list + (cons (fn (car list)) (map fn (cdr list)))))) + +(map (lambda (n) (+ n 1)) '(1 2 3)) + +(defmacro let (vars body) + `((lambda ,(map car vars) ,body) . ,(map cadr vars))) + +(let ((a 8) (b 9)) (+ a b)) |