Last active
July 8, 2016 10:11
-
-
Save hyotang666/a5f6c2b66ee9d4fa622a536677e9f8bd 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
(defmacro my-let(binds &body body) | |
`((lambda,(mapcar #'ensure-car binds) | |
,@body) | |
,@(mapcar #'init-form binds))) | |
(defun ensure-car (arg) | |
(if(listp arg) | |
(car arg) | |
arg)) | |
(defun init-form (arg) | |
(if(listp arg) | |
(cadr arg) | |
nil)) | |
(defmacro my-let*(binds &body body) | |
(labels((rec(binds) | |
(if(endp binds) | |
body | |
(body(car binds)(cdr binds)))) | |
(body(bind rest) | |
`(((lambda(,(ensure-car bind)) | |
,@(rec rest)) | |
,(init-form bind))))) | |
(car(rec binds)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment