((foo 2) 3)
- These functions are "curried". `foo 2` returns a `2`-fooer, which waits for an argument like `3` and then foos `2` to it. `( + ) 2` returns a `2`-adder, which waits for an argument like `3` and then adds `2` to it. For further reading:
+ These functions are "curried". `foo 2` returns a `2`-fooer, which waits for an argument like `3` and then foos `2` to it. `( + ) 2` returns a `2`-adder, which waits for an argument like `3` and then adds `2` to it. For further reading:
* [[!wikipedia Currying]]
But supposing you had constructed appropriate values for `+` and `3` and `2`, you'd place them in the ellided positions in:
(((\three (\two ((... three) two))) ...) ...)
-
+
In an ordinary imperatival language like C:
int three = 3;
(let* [(three (+ 1 2))]
(let* [(two 2)]
(+ three two)))
-
+
It was also asked whether the `(+ 1 2)` computation would be performed before or after it was bound to the variable `three`. That's a terrific question. Let's say this: both strategies could be reasonable designs for a language. We are going to discuss this carefully in coming weeks. In fact Scheme and OCaml make the same design choice. But you should think of the underlying form of the `let`-statement as not settling this by itself.
Repeating our starting point for reference:
int x = 3;
x = 2;
-
+
<em>but it's not the same!</em> In the latter case we have mutation, in the former case we don't. You will learn to recognize the difference as we proceed.
The OCaml expression just means: