mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-11-26 09:21:00 +03:00
An overly simplified explanation of currying in OCaml tutorial.
This commit is contained in:
parent
55c269cc3c
commit
d9110cf7bc
@ -31,7 +31,7 @@ val a : int = 99
|
||||
```
|
||||
|
||||
For a source file you can use "ocamlc -i /path/to/file.ml" command
|
||||
to print all names and signatures.
|
||||
to print all names and type signatures.
|
||||
|
||||
```
|
||||
$ cat sigtest.ml
|
||||
@ -47,7 +47,13 @@ val a : int
|
||||
```
|
||||
|
||||
Note that type signatures of functions of multiple arguments are
|
||||
written in curried form.
|
||||
written in curried form. A function that takes multiple arguments can be
|
||||
represented as a composition of functions that take only one argument.
|
||||
The "f(x,y) = x + y" function from the example above applied to
|
||||
arguments 2 and 3 is equivalent to the "f0(y) = 2 + y" function applied to 3.
|
||||
Hence the "int -> int -> int" signature, which can be read as
|
||||
"(int -> int) -> int".
|
||||
|
||||
|
||||
```ocaml
|
||||
(*** Comments ***)
|
||||
|
Loading…
Reference in New Issue
Block a user