我們可以在ocaml的if-else循環中執行多個操作嗎?嵌套if - else語句-ocaml
我努力做到以下幾點:
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
。
我在這種情況下怎麼辦?
請指教。
謝謝。
appendtocode返回一個字符串。我想調用它,並減少b的值。 – JJunior 2010-11-28 21:44:34