How to return tree's leaves in a list in Haskell

Published: 5/10/2017
How to return tree's leaves in a list in Haskell
Source: STACKOVERFLOW.COM

I have this code so far: data BinaryTree a = Null | Node a (BinaryTree a) (BinaryTree a) treeLeaves :: BinaryTree a -> [a] treeLeaves tree = case tree of Null -> [] Node v t1 t2 -> [] ++ treeLeaves t1 ++ treeLeaves t2 I am not sure what I'm doing wrong. It outputs an empty list.

Read more
Related news
Comment