I have a following function that defines a tree:
datatype 'a tree = leaf of 'a |
node of 'a tree * 'a tree;
fun cat(leaf(s)) = s
| cat(node(t1,t2)) = cat(t1) ^ " " ^ cat(t2);
The cat function is used to concatenates strings input to the string tree. I know it is not tail recursive since the definition use the function itself for recursion. Now I am thinking if there is any way to make it in the ways of tail recursive? Thanks in advance for any helps.