diff options
author | kartofen <mladenovnasko0@gmail.com> | 2024-09-01 11:35:38 +0300 |
---|---|---|
committer | kartofen <mladenovnasko0@gmail.com> | 2024-09-01 11:35:38 +0300 |
commit | 6def1ae9744b0f56ee04d05db622f4b2a8ca96e9 (patch) | |
tree | 8bfb703787bc401277db9fe7803120e04070ac24 /files | |
parent | 329166705de225bc766e56cc77765430065c456d (diff) |
macro fun
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)) |