Exercises part 2
Implement the following functions in a provably total way without "cheating". Note: It is not necessary to implement these in a tail recursive way.
-
Implement function
depthfor rose trees. This should return the maximal number ofNodeconstructors from the current node to the farthest child node. For instance, the current node should be at depth one, all its direct child nodes are at depth two, their immediate child nodes at depth three and so on. -
Implement interface
Eqfor rose trees. -
Implement interface
Functorfor rose trees. -
For the fun of it: Implement interface
Showfor rose trees. -
In order not to forget how to program with dependent types, implement function
treeToVectfor converting a rose tree to a vector of the correct size.Hint: Make sure to follow the same recursion scheme as in the implementation of
treeSize. Otherwise, this might be very hard to get to work.