Charles Haro
Charles Haro

Reputation: 1886

ocaml Error: This expression has type expr but is here used with type unit -> expr

I can't figure out what this error means, I've never seen if before the line it is complaining about is the line that contains x -> let I was using match with before this but it was still giving me the same error.

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));;

each of my the builds returns a expr and this is supposed to build one big expr Any help would be greatly appreciated. Thanks in advance! :D

Upvotes: 0

Views: 467

Answers (1)

Jeffrey Scofield
Jeffrey Scofield

Reputation: 66823

Perhaps buildX and buildY are supposed to take an argument?

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

Upvotes: 3

Related Questions