Last active
December 25, 2015 07:49
-
-
Save ifesdjeen/6941906 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 | |
[bindings & body] | |
(assert (-> bindings count even?) "Bindings count can only be even.") | |
`((fn [~@(take-nth 2 bindings)] | |
~@body) | |
~@(take-nth 2 (rest bindings)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
One of the ways to implement let is to create a temporary function scope that will have required
bindings, and call this function with params that represent arguments.
For example, if you have bindings like
[a 1 b 2]
, you'll takea
andb
as variable names (bindings),and
1
and2
as values, that you'll call function with.This means that our let will expand:
To: