我必须找到一个元组列表的最小值,但我只想返回元组中snd
元素的最小值,而不是整个元组。不幸的是,我在以下代码中遇到以下错误,我不知道为什么。l 参数是一个元组列表(float * float)
let rec minRight l = match l with
| [] -> raise (Arg.Bad "minRight: empty list")
| [x]-> x
| (_,y)::xs -> min y (minRight xs)
错误:
| (_,y)::xs -> min y (minRight xs)
Error: This expression has type 'a but an expression was expected of type
'b * 'a
提前致谢。