Guest User

Untitled

a guest
Dec 16th, 2017
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. (* rimuovi: 'a -> 'a list -> 'a list *)
  2. let rec rimuovi x lst =
  3. match lst with
  4. [] -> []
  5. | el::rest -> if el=x then rest
  6. else el::(rimuovi x rest);;
  7.  
  8. (* path_coprente: 'a tree -> 'a list -> 'a list *)
  9. let rec path_coprente t lst =
  10. match t with
  11. Empty -> failwith "err"
  12. | Tr(x,Empty,Empty) -> if lst=[] || lst=[x] then [x]
  13. else failwith "err"
  14. | Tr(x,l,r) -> if List.mem x lst then x::(try path_coprente l (rimuovi x lst)
  15. with _ -> path_coprente r (rimuovi x lst))
Advertisement
Add Comment
Please, Sign In to add comment