Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let tree2mtree ?(l=0) t =
- let rec assignerId comp arbreListe = match arbreListe with
- | [] -> []
- | [St 1] -> [St 1]
- | [St _] -> [St comp]
- | St 1::xt -> St 1::assignerId (comp) xt
- | x::xt -> St comp::assignerId (comp+1) xt
- in
- let rec boucle compteur arbre =
- match arbre with
- | St _ -> []
- | Leaf _ -> []
- | Tree(a,b,[]) -> [(compteur, arbre)]
- | Tree(a,b,g) -> (compteur,Tree(a,b,assignerId (compteur+1) (g)))::snd(fold_left(fun accumulateur tree ->
- (fst accumulateur+1,snd accumulateur @((boucle (fst accumulateur+1) tree) )))
- (compteur,[]) g)
- in
- boucle 1 t
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement