Reputation: 123
I have two questions concerning OCaml.
Firstly, what does the ==
means when defining a type
.
For example you can see at the end of this page the following code:
type compteur == int;;
Then what is the difference with:
type compteur = int;;
Moreover I have an other question concerning pattern matching. How to say that you want to return nothing on a case.
For example let's say I have a function f
that returns a boolean:
let rec f v = function
| t when t<v -> true
| t when t > v -> f (t-1)
| t when t = v -> (* here a code to say that you do nothing, and wait for the other recursive call *)
Upvotes: 2
Views: 79
Reputation: 370122
type compteur == int
is a syntax error. The only valid way to define a type alias is with =
, not ==
. It's just a typo on the page you linked.
How to say that you want to return nothing on a case.
The only way to return nothing from a function would be to exit the program, raise an exception or loop (or recur) infinitely. Otherwise a function always returns a value.
here a code to say that you do nothing, and wait for the other recursive call
What other recursive call? In the case that t = v
only the code for that case will run. There is no other code to wait on.
Upvotes: 3