我正在尝试构建一个列表,其中包含列表最小值出现的索引。
let rec max_index l =
let rec helper inList min builtList index =
match inList with
| [] -> builtList
| x :: xs ->
if (x < min) then
helper xs x index :: builtList index + 1 //line 63
else
helper xs min builtList index + 1
in helper l 100000 [] 0;;
第63行出现了以下错误。
Error: This expression has type 'a list -> 'a list
but an expression was expected of type 'a
The type variable 'a occurs inside 'a list -> 'a list
期望'a?'类型的表达式?我不确定为什么会这么说。我猜可能与index::builtList
有关。
This expression has type float but an expression was expected of type int
- line 62。 - Collinif (x < min) then
得到的吗? - N_A