Created
April 4, 2011 18:52
-
-
Save eschulte/902174 to your computer and use it in GitHub Desktop.
use bind to restructure arguments to lambda expressions
This file contains hidden or 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 lambdab ((&rest instrs) &rest body) | |
"Use `bind' to allow restructuring of argument to lambda expressions." | |
(declare (indent 1)) | |
(let* ((evald-instrs instrs) | |
(syms (mapcar (lambda (_) (gensym)) evald-instrs))) | |
`(lambda ,syms (bind ,(mapcar #'list evald-instrs syms) ,@body)))) | |
;; example usage | |
(let ((fn (lambdab ((a b) c) (cons a c)))) | |
(funcall fn '(1 2) 3)) ;; => (1 . 3) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Eric,
This looks pretty cool. I'd be happy to add it to metabang-bind. Look for it sometime this week.
regards,