Bonjour, je ne comprends pas d’où viens mon erreur pour la fonction parameters,
Échec sur les arguments suivants:
Empty
voici mon code:
let rec height t =
match t with
Empty -> (-1)
|Bin (x,g,d) -> 1+max(height g) ( height d)
let arity t=
match t with
Empty->(-1)
|Bin(x,g,d)->match (g,d) with
(Empty,Empty)->0
|(Empty,_)->1
|(_,Empty)->1
|(_,_)->2
let rec arity2 t =
match t with
Empty -> 0
| Bin(x,left,right) -> if arity t = 2
then 1 + arity2 left + arity2 right
else 0 + arity2 left + arity2 right
let rec arity1 t =
match t with
Empty -> 0
| Bin(x,left,right) -> if arity t = 1
then 1 + arity1 left + arity1 right
else 0 + arity1 left + arity1 right
let rec size tree =
match tree with
Empty -> 1
|Bin(x,left,right)->1+(size left) + (size right)
let rec internal t =
match t with
Empty -> 0
|Bin(x,left,right) -> 1+ internal left + internal right
let nb_leaves t = size t - internal t
let parameters t = match t with
Empty->(size t,nb_leaves t,arity1 t,arity2 t,0)
|_->(size t,nb_leaves t,arity1 t,arity2 t,height t)
Merci.