My Tree definition is as follows:
data Tree a = Leaf a | Node (Tree a) (Tree a) deriving (Show)
I want to write a filter function that picks only every 3rd element of an array (1st, 4th, 7th, ...). As an example, suppose my tree is as follows:
Node
(Node
(Node
(Leaf 'a')
(Leaf 'b'))
(Leaf 'c'))
(Node
(Node
(Leaf 'd')
(Leaf 'e'))
(Leaf 'f'))
Then the filter function should result in a new tree as:
Node (Leaf 'a') (Leaf 'd')