Problem 70a
A multiway tree has a root element and a set of successors which are multiway trees themselves. A multiway tree is never empty, although it's list of children may be an empty list.
- Define type to a represent multiway trees.
- Create a tree instance to represent the tree in the diagram below.
- Write a function to count all nodes of the tree.
Unit Test
import Html
import List
type MTree a =
-- your definition goes here
mtree70 =
-- instantiate the multiway tree illutrated above
count : MTree a -> Int
-- your definition goes here
main =
Html.text
(if (test) then
"Your implementation passed all tests."
else
"Your implementation failed at least one test."
)
test : Bool
test =
List.all ((==) True)
[ count mtree70 == 7
]