Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ifesdjeen
Last active December 21, 2015 06:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ifesdjeen/6262725 to your computer and use it in GitHub Desktop.
Save ifesdjeen/6262725 to your computer and use it in GitHub Desktop.
In Control Structures of Let-over-lambda, they describe an idea of taking bindings and writing a macro that substitutes symbols for values. That's pretty much same thing. quote from the book itself: The expansion uses Labels special form to bind a function around the provided body. The function is named according to the symbol used in the named …
;; Writing something remotely reminding nlet
(defmacro body-and-bindings
[bindings & body]
`(let [~(first bindings) 1
~(second bindings) 2]
~@body))
;; Expands to:
(let* [a 1 b 2] (+ a b))
(body-and-bindings [a b] (+ a b))
;; => 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment