Working on a function that given a SuffixTree as input, outputs the list of integers in that suffix tree. For example. getIndices tree1 = [2,4,1,3,5,0] . The order of the list of integers does not matter. I am getting the error, on the second last line of the function: "Couldn't match expected type 'SuffixTree' with actual type '[SuffixTree]'
". I have thought about this for a long time now and have had no luck. Any help would be greatly appreciated.
data SuffixTree = Leaf Int | Node [ ( String, SuffixTree ) ]
deriving (Eq,Ord,Show)
text1 :: String
text1 = "banana"
tree1 :: SuffixTree
tree1 = Node [("banana",Leaf 0),
("a",Node [("",Leaf 5),
("na",Node [("",Leaf 3),
("na",Leaf 1)])]),
("na",Node [("",Leaf 4),
("na",Leaf 2)])]
------------------------------------------------------------------
getIndices :: SuffixTree -> [ Int ]
getIndices sufTree = getIndices' sufTree []
where getIndices' :: SuffixTree -> [Int] -> [Int]
getIndices' (Node ((_, Node xs):ys)) c
| Node xs == Node [] = c
| otherwise = getIndices' ((Node xs):([Node ys])) c
getIndices' (Node ((_,Leaf i):xs)) c = getIndices' (Node xs) (i:c)