【发布时间】:2015-05-28 06:16:39
【问题描述】:
我正在尝试使用以下代码递归查找 ocaml 列表中的第 n 个元素。
let rec get_val x n = match x with
[] -> -1
| h::t -> if (n=0) then h else get_val t (n-1)
;;
print_int get_val [1; 2; 3] 1;;
但是这段代码给了我错误
This function has type int -> unit
It is applied to too many arguments; maybe you forgot a `;'.
【问题讨论】: