I am currently exploring OCaml
and wrote the following implementation of deleting a node from a binary tree
let rec deleteNode tree' value =
match tree' with
| Empty -> Empty
| Node(left, nodeValue, right) -> if value < nodeValue then
if value < nodeValue then
Node((deleteNode left value), nodeValue, right)
else if value > nodeValue then
Node(left, nodeValue, (deleteNode right value))
else if left = Empty && right = Empty then
Empty
else if left = Empty then
right
else if right = Empty then
left
else
let newValue = minValue right in
Node(left, newValue, (deleteNode right newValue))
Where my tree type is
type tree =
| Empty
| Node of tree * int * tree
I am looking for a review of my code so that I can improve my OCaml
and functional
skills.