Created
October 22, 2019 12:26
-
-
Save DeLaGuardo/bae97fb7da8619cbd78796ac24119256 to your computer and use it in GitHub Desktop.
Lambda analyze
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
{:paths ["."]} |
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
(ns lambda) | |
(defmacro memoize [lambda] | |
`(let [mem-fn# (memoize | |
(fn ~(vec (cons 'mem-fn (nth lambda 2))) | |
(let [~(nth lambda 1) (fn ~(nth lambda 2) | |
~(concat (list 'mem-fn 'mem-fn) (nth lambda 2)))] | |
~@(drop 3 lambda))))] | |
(partial mem-fn# mem-fn#))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment