I am trying to make a function that will print binary trees. My binary tree datatype looks like this:
datatype 'a BT = empty | bTree of 'a * 'a BT * 'a BT;
I have also made a function that prints integers, which I will be using for the nodes:
fun printInt n = print (Int.toString n);
As you can see, the BT datatype has 3 nodes ('a,'a BT, 'a BT), I have started making a displayTree function, but cannot find a way to print out the unit types that my printInt function returns. I'm sure that there are other ways to do this, but in this case, how would I return three concatenated unit types. Here is what I have so far (I understand that the @s are incorrect).
fun displayTree T =
let
val bTree (root, left, right) = T;
in
(printInt root)@ (displayTree left) @ (displayTree right)
end;
I am not worried about the line formatting of the trees yet. I am just unsure of how to append my (printInt root) to the recursive calls.
EDIT:
I want the displayTree function to be polymorphic