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