Created
March 9, 2019 12:52
-
-
Save agumonkey/30012753a746183f69f01f6227089e9b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(cl-flet ((fun (x) (1+ x))) | |
(fun 0)) | |
(let ((fun (lambda (x) (1+ x)))) | |
(fun 0)) | |
(defmacro lem (bs &rest body) | |
(cl-flet ((fun? (form) | |
(and (listp form) | |
(eq (length form) 3) | |
(eq (car form) 'lambda)))) | |
(if (null bs) | |
`(progn ,@body) | |
(let* ((h (car bs)) | |
(k (car h)) | |
(v (cadr h))) | |
(if (fun? v) | |
(let ((~bs (cadr v)) | |
(~b (caddr v))) | |
`(cl-flet ((,k ,~bs ,~b)) | |
(lem ,(cdr bs) ,@body))) | |
`(let ((,k ,v)) | |
(lem ,(cdr bs) ,@body))))))) | |
(lem ((n 0)) | |
n) | |
(lem ((x 0) | |
(fun (lambda (x) (1+ x))) | |
(n (1+ x))) | |
(fun n)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment