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

ocaml错误:此表达式具有类型expr,但此处与类型unit一起使用->;expr,ocaml,ocamlbuild,Ocaml,Ocamlbuild,我不明白这个错误是什么意思,我以前从来没有见过 它抱怨的行是包含x->let的行 在此之前,我使用了match with,但它仍然给我相同的错误 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->let的行 在此之前,我使用了match with,但它仍然给我相同的错误

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

也许
buildX
buildY
应该接受一个参数

# let f () = 14;;
val f : unit -> int = <fun>
# f ;;
- : unit -> int = <fun>
# f ();;
- : int = 14
#设f()=14;;
val f:单位->整数=
#f;;
-:单位->整数=
#f();;
-:int=14

也许
buildX
buildY
应该接受一个参数

# let f () = 14;;
val f : unit -> int = <fun>
# f ;;
- : unit -> int = <fun>
# f ();;
- : int = 14
#设f()=14;;
val f:单位->整数=
#f;;
-:单位->整数=
#f();;
-:int=14

它们不是:/it在OCaml中有empty(),empty()是一个值。我猜@JeffreyScofield发现了。非常感谢><我仍然在OCaml中是noob hahahahahy他们不是:/it在OCaml中有empty(),empty()是一个值。我猜@JeffreyScofield发现了。非常感谢><我仍然在OCaml中是noob hahahahawa没有定义,或者至少是代码段中所有绑定的声明,很难分辨。如果没有定义,或者至少是代码段中所有绑定的声明,很难分辨。