I found a wrong code in chapter 1.3 of “The OCaml system release 4.07 Documentation and user’s manual” in http://caml.inria.fr/pub/docs/manual-ocaml/coreexamples.html
It says bellow sample codes
But it doesn’t work well
List.map (function n -> n * 2 + 1) [0;1;2;3;4];;
- : int list = [1; 3; 5; 7; 9]
This sample code is just wrong. In OCaml 4.07.1, the code returns bellow error message.
List.map (function n -> n * 2 + 1) [0;1;2;3;4];;
Error: This expression should not be a function, the expected type is
'a Core.List.t
The right sample code is:
List.map ~f:(function n -> n * 2 + 1) [0;1;2;3;4];;
- : int list = [1; 3; 5; 7; 9]