Given the following simple Tree
data Tree =
Leaf
| Node Tree Tree
deriving (Eq, Show)
is there a way to return an infinite amount of nodes (a Tree
with just Nodes
, no leaves) using recursion?
So far I only know how to return data types such as Boolean
and Integer
. How do I start about returning a Tree
?
infiniteTree :: Tree
infiniteTree = Node infiniteTree infiniteTree