Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. let tree2mtree ?(l=0) t =
  2. let rec assignerId comp arbreListe = match arbreListe with
  3. | [] -> []
  4. | [St 1] -> [St 1]
  5. | [St _] -> [St comp]
  6. | St 1::xt -> St 1::assignerId (comp) xt
  7. | x::xt -> St comp::assignerId (comp+1) xt
  8. in
  9. let rec boucle compteur arbre =
  10. match arbre with
  11. | St _ -> []
  12. | Leaf _ -> []
  13. | Tree(a,b,[]) -> [(compteur, arbre)]
  14. | Tree(a,b,g) -> (compteur,Tree(a,b,assignerId (compteur+1) (g)))::snd(fold_left(fun accumulateur tree ->
  15. (fst accumulateur+1,snd accumulateur @((boucle (fst accumulateur+1) tree) )))
  16. (compteur,[]) g)
  17. in
  18.  
  19. boucle 1 t
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement