Hello,
I keep finding examples of recursion on integers, but could not get anything to work with more complex typeS. Suppose I have a Tree defined as :
type Tree =
| Leaf of int
| Node of Tree * Tree
Now I have an object of this type as follows :
let MyTree = Node (Leaf (3), Node (Node(Leaf (2), Leaf (4)), Leaf(1)))
How would I go and calculate recursively the sum of all the integers carried by the leaves ?
Thanks in advance for your help.