Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (* rimuovi: 'a -> 'a list -> 'a list *)
- let rec rimuovi x lst =
- match lst with
- [] -> []
- | el::rest -> if el=x then rest
- else el::(rimuovi x rest);;
- (* path_coprente: 'a tree -> 'a list -> 'a list *)
- let rec path_coprente t lst =
- match t with
- Empty -> failwith "err"
- | Tr(x,Empty,Empty) -> if lst=[] || lst=[x] then [x]
- else failwith "err"
- | Tr(x,l,r) -> if List.mem x lst then x::(try path_coprente l (rimuovi x lst)
- with _ -> path_coprente r (rimuovi x lst))
Advertisement
Add Comment
Please, Sign In to add comment