Skip to content

Instantly share code, notes, and snippets.

@hyotang666
Last active July 8, 2016 10:11
Show Gist options
  • Save hyotang666/a5f6c2b66ee9d4fa622a536677e9f8bd to your computer and use it in GitHub Desktop.
Save hyotang666/a5f6c2b66ee9d4fa622a536677e9f8bd to your computer and use it in GitHub Desktop.
(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