Closed danielruc91 closed 1 year ago
The code
let f = function
…
is shorthand for
let f x =
match x with
…
This syntax is introduced in subsection 3.1.6 (Data and Types → Lists → Immediate matches).
To find out where this notation is introduced I first generated a list of all files that contain the string = function
by using the command grep -rl '= function' src/chapters/
in the root of the repository. I then went through this generated list to figure out which file comes earliest in the book.
Thanks very much! I indeed missed that section.
I am reading on this page that find this:
While the
let x = function <some pattern matching>
is intuitive at the first glance, I am not able to find syntax like this in previous chapters. By checking back, I believe the function definition syntax can belet f x = <funtion body>
orlet f = fun x-> <function body>
.Is this syntax introduced some where in previous chapters?