Skip to content

Instantly share code, notes, and snippets.

@agumonkey agumonkey/lem.el
Created Mar 9, 2019

Embed
What would you like to do?
(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
You can’t perform that action at this time.