Hello,
let l = [(2;"a");(5,"b");(1,"dasdf")];;
How to use a function List.stable_sort
val stable_sort :|cmp:('a -> 'a -> int) -> 'a list -> 'a list
|
Here, 'a is un unknown type. I your exemple: int * string
stable_sort need to be given a function with type:
int * string -> int * string -> int
or, if you don't care about the ints :
'a * string -> 'a * string -> int
let mycomp a b = compare (fst a) (fst b)
How to write correctly
"l = List.stable_sort (cmp (fst 'a)(snd 'a)????) l;;"
Hum. you are mixing things here.
let l = List.stable_sort mycomp l;;
Hoping it will help
Matt
--
You received this message because you are subscribed to the Google Groups
"ocaml-developer" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/ocaml-developer?hl=en
For other OCaml forums, see http://caml.inria.fr/resources/forums.en.html