Hacker News new | ask | show | jobs
by arocks 4017 days ago
It seems `int_of_float` and `float_of_int` are deprecated by the Jane Streets Core library. It even throws errors on utop. I believe they need to be replaced by `Int.of_float` and `Float.of_int` respectively.

EDIT: Some more corrections:

1. `List.hd []` doesn't raise an error as its return type is an option. So the result is a `None`.

2. `List.map` and `List.filter` arguments should be reversed. First argument should be a list and the second should be the mapping function.

1 comments

The code examples doesn't use Jane Streets Core as the primary standard library. If you do, for example by adding `open Core.Std` to your .ocamlinit, you'll get the behaviour you're describing.

It is probably a good idea to use Core, but for this introduction I wanted as little requirements as possible.

edit: spelling

Right. Since you mention the installation instructions from Real World OCaml and the examples in the book need you to use Core, it is likely that beginners would experience these issues.
That's a good point. I'll add a note to explicitly say that the examples doesn't use Core.