Created
February 28, 2011 11:16
-
-
Save iorlas/847194 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
def f1(x): | |
x = x | |
def f2(y): | |
x += y | |
return x | |
return f2 | |
(defn f1 [x] | |
(let [x (atom x)] | |
(fn [y] | |
(swap! x + y) | |
@x))) | |
> ((f1 1) 2) | |
3 | |
(defun f1 (x) | |
(let ((x x)) | |
(lambda (y) | |
(setq x (+ x y)) | |
x))) | |
> (funcall (f1 1) 2) | |
3 | |
>>> def f1(x): | |
... x = x | |
... return lambda y: x+y | |
>>> f1(1)(2) | |
3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment