Sml folding a tree
I am trying to get the product of a tree by using the fold function so far this is what I have. I am confused on how to use the fold method while transversing the tree datatype 'a bin_tree = Leaf of 'a | Node of 'a bin_tree * 'a bin_tree fun treefold g z Empty = z | treefold g z (Node (l, x, r)) = g(x, g(treefold g z l, treefold g z r) First, some pointers about what isn't quite in order in your attempt. The base case of your treefold function matches against the value constructor Empty , but you don't define the bin_tree datatype to include an Empty value constructor. As John Coleman points