Skip to content

Instantly share code, notes, and snippets.

@eschulte
Created April 4, 2011 18:52
Show Gist options
  • Save eschulte/902174 to your computer and use it in GitHub Desktop.
Save eschulte/902174 to your computer and use it in GitHub Desktop.
use bind to restructure arguments to lambda expressions
(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)
@gwkkwg
Copy link

gwkkwg commented Apr 5, 2011

Hi Eric,

This looks pretty cool. I'd be happy to add it to metabang-bind. Look for it sometime this week.

regards,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment