Created
July 19, 2016 22:39
-
-
Save sli/01cc480972ccd7a4fc444782c4ab4ded to your computer and use it in GitHub Desktop.
Figuring out Lisp by implementing partials in hy.
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
(defn partial [f arg &rest args1] | |
(defn p [&rest args2] | |
(apply f (+ (list* arg (list args1)) (list args2))))) | |
(defn add [a &rest b] | |
(+ a (reduce + b))) | |
(def add10 (partial add 10)) | |
(print (add10 15 20)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment