Skip to content

Instantly share code, notes, and snippets.

@agumonkey
Created March 9, 2019 12:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save agumonkey/30012753a746183f69f01f6227089e9b to your computer and use it in GitHub Desktop.
Save agumonkey/30012753a746183f69f01f6227089e9b to your computer and use it in GitHub Desktop.
(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