I'm doing a small project in Haskell, and I'm having difficulty in creating a function Paths of a "Rose Tree". My Rose Tree has a different point where I can have four possibilities since the beginning.
What I was trying to do was:
data RoseTree a = Start [RoseTree Movimento] | Node a [RoseTree Movimento]
deriving (Eq, Show)
paths :: RoseTree Movimento -> [[Movimento]]
paths (Start []) = []
paths (Node n []) = [[n]]
paths (Node n ns) = map ((:) n . concat . paths) ns
paths (Start xs) = undefined
PS -> Tree Example :
data Movimento = AndarEsquerda | AndarDireita | Trepar | InterageCaixa
deriving (Show, Read, Eq, Ord)
Start [Node AndarEsquerda [Node AndarDireita [Node AndarEsquerda [],Node Trepar []]],Node Trepar [Node AndarDireita [Node AndarDireita []],Node AndarEsquerda [Node AndarEsquerda []]]]
Expected output:
[[AndarEsquerda, AndarDireita, AndarEsquerda],
[AndarEsquerda, AndarDireita, Trepar],
[Trepar, AndarDireita, AndarDireita],
[Trepar, AndarEsquerda, AndarEsquerda]]