Bonjour,
je n'arrive pas à corriger ma fonction sur le moodle;
voici le message d'errer :
Error: This expression has type bool but an expression was expected of type
int
let p = fun x -> x mod 2 = 0;;
let rec size p t = match t with
|Empty -> 0
|Bin(v,l,r) -> p v + size p l + size p r;;
let rec nb_feuille p t = match t with
|Empty -> 0
|Bin(v,Empty,Empty) -> p v
|Bin(v,l,r) -> nb_feuille p l + nb_feuille p r;;
let rec arity1 p t = match t with
|Empty -> 0
|Bin(v,Empty,Empty) -> p v
|Bin(v,Empty, r) -> 1 + arity1 p r
|Bin(v,l,Empty) -> 1 + arity1 p l
|Bin(v,l,r) -> ( arity1 p l ) + (arity1 p r);;
let rec arity2 p t = match t with
|Empty -> 0
|Bin(v,Empty,Empty) -> p v
|Bin(v,Empty, r) -> arity2 p r
|Bin(v,l,Empty) -> arity2 p l
|Bin(v,l,r) -> 1 + ( arity2 p l ) + (arity2 p r);;
let rec height1 p t = match t with
Empty -> -1
|Bin(x,Empty,Empty) -> p x
|Bin(r,g,d) -> p r + max (height1 p g)(height1 p d);;
let rec height2 p t = match t with
Empty -> -1
|Bin(x,Empty,Empty) -> p x
|Bin(r,g,d) -> p r + max (height2 p g)(height2 p d);;
let rec parameters_gen p t =match t with
|Empty ->(0,0,0,0,-1,-1)
|Bin(x,g,d)->let s = size p t
in
let f = nb_feuille p t
in
let nA1 = arity1 p t
in
let nA2 = arity2 p t
in
let h1 = height1 p t
in
let h2 = height2 p t
in (s,f,nA1,nA2,h1,h2)
cordialement.