what is the difference here ?
| Newsgroups | gmane.comp.lang.ocaml.beginners |
|---|---|
| Message-ID | <[email protected]> |
Hello,
I found the solution to exercise 2 of the 99 ocaml problems.
The solution I found was this :
let rec last_two list =
match list with
| [] | [_] -> None
| [x;y] -> Some (x,y)
| _::xs -> last_two xs ;;
Now I wonder something.
For me it looks like [x;y] and _::xs are the same.
If I understand it right you can write [x;y] as x::y and _::xs looks
then the same to me.
But if I change [x;y] to x::y then I see a message that _:xs is not used.
Can someone explain in simple words what is the difference between those
two ?
Roelof