Haskell: Get path from every leaf node to root in a Bin tree structure
问题 I've got work to do, but i dunno how to do it. I have Bin tree 1 / \ 2 3 / \ / \ 4 5 6 7 And I need to find the way from root to Node with the coord [i, j]. For example: (2, 2) -> [1, 3, 6] fromRoot :: Int -> Int -> Tree a -> [a] I wrote some function for Index and BinTree, but how to make main function i dont know. data Tree a = Node (Tree a) a (Tree a) index :: Tree a -> Int -> Int -> a index (Node _ x _ ) 0 _ = x index (Node l x r) i j | ((border i)<j) = index r (i-1) (j-(border i)-1) |