ocaml函数应用了太多参数
我尝试使用下面的代码从i->0执行递归并输出空白ocaml函数应用了太多参数,ocaml,Ocaml,我尝试使用下面的代码从i->0执行递归并输出空白 let print_tab fmt i = match i with | 0 -> put fmt "%s" "" | _ -> put fmt "%s" " " ; print_tab fmt (i-1) 但是它不起作用,如下所示显示错误 Error: This function is applied to too many arguments; maybe you forgot a `;'
let print_tab fmt i =
match i with
| 0 -> put fmt "%s" ""
| _ -> put fmt "%s" " " ; print_tab fmt (i-1)
但是它不起作用,如下所示显示错误
Error: This function is applied to too many arguments;
maybe you forgot a `;'
我尝试了另一个代码
let print_tab fmt = function
| 0 -> put fmt "%s" ""
| j -> put fmt "%s" " " ; print_tab fmt (j-1)
但是它得到了相同的错误,有什么问题吗?错误是您忘记了
rec
,因此您的函数不是递归函数,并且尝试使用先前定义的print\u tab
我需要声明i=ref吗?函数是什么?