ocaml 错误:此表达式具有 expr 类型,但此处与类型单位 -> expr 一起使用



我不知道这个错误是什么意思,我以前从未见过它抱怨的行是包含 x -> let 的行在此之前,我正在使用匹配,但它仍然给我同样的错误。

let rec build (rand,depth) = match depth with
 | 0 -> if rand(0,2) == 0 then buildX else buildY
 | x -> let r =  rand(0, 5) in
     if r == 0 then buildSine (build (rand, x -1))
     else if r == 1 then buildCosine (build (rand, x -1))
     else if r == 2 then buildAverage (build (rand,x -1), build (rand,x-1))
     else if r == 3 then buildTimes (build (rand, x -1), build (rand, x-1))
     else buildThresh (build(rand, x-1), build(rand, x-1),               
                   build(rand, x-1), build(rand, x-1));;

我的每个构建都返回一个 expr,这应该构建一个大的 expr任何帮助将不胜感激。提前感谢!:D

也许buildXbuildY应该争论一下?

# let f () = 14;;
val f : unit -> int = <fun>
# f ;;
- : unit -> int = <fun>
# f ();;
- : int = 14

相关内容

最新更新