I am doing Exercise 3 from Homework 2 in http://ift.tt/1YrZUO2
build :: [LogMessage] -> MessageTree
build [x] = Node Leaf x Leaf
build [x,y] = Node (build [x]) y Leaf
build [x,y,z] = Node (Node (build [x]) y Leaf) z Leaf
I have a problem where I do not know how to end the pattern matching. It would just keep expanding to [x,y,z,_]
and then [x,y,z,_,_]
and so on. How do I stop this?
Aucun commentaire:
Enregistrer un commentaire