【发布时间】:2016-10-05 04:38:37
【问题描述】:
我们可以在 ocaml 的 if-else 循环中执行多项操作吗?
我正在尝试执行以下操作:
let rec appendtolist n list b =
let f x =
if ( b < 0 ) then x
else if (b == 0) then ((appendtocode n (List.hd list) ) (b-1)) (* THIS LINE *)
else ((appendtocode n (List.hd list)) :: (appendtolist n (List.tl list) (b-1)) )
in
f list
;;
编译器在我加粗的那一行抱怨:
这个表达式不是函数,不能应用
我想在b==0 时调用我的函数,同时减少b 的值。
在这种情况下我该怎么做?
请指教。
谢谢。
【问题讨论】:
标签: ocaml