Strike
05-21-2003, 03:30 PM
Okay, I'm trying to translate my Haskel bubble sort into O'Caml and I'm not understanding why the interpreter doesn't like this:
# let rec bsorthelper lst =
match lst with
[] -> ([], false)
| [x] -> ([x], false)
| x :: xs ->
let (y::ys, changed) = bsorthelper xs in
if x > y then (y::x::ys, true) else (x::y::ys, changed);;
Warning: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
([], _)
val bsorthelper : 'a list -> 'a list * bool = <fun>
#
And it has the let clause underlined saying that it isn't exhaustive ... what gives?
# let rec bsorthelper lst =
match lst with
[] -> ([], false)
| [x] -> ([x], false)
| x :: xs ->
let (y::ys, changed) = bsorthelper xs in
if x > y then (y::x::ys, true) else (x::y::ys, changed);;
Warning: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
([], _)
val bsorthelper : 'a list -> 'a list * bool = <fun>
#
And it has the let clause underlined saying that it isn't exhaustive ... what gives?