title: Walk randomly through a binary tree?
body: <p>I'm making a program that takes a tree and randomly picks a branch (left or right) and returns those values in a list. For some reason it's not working. Any help?</p>
  
  <p>Example:</p>
  
  <pre><code>~(rand-walk (tree 1 (leaf 2) (leaf 3)))
  (1 2)
  </code></pre>
  
  <p>This is what I have so far:</p>
  
  <pre><code>(define (rand-walk tr)
   (if (empty-tree? tr) '()
     (if (leaf? tr) tr
        (if (equal? (random 1) 0)
                (cons ((root-value tr)(root-value (left-subtree tr))) '())
                (cons ((root-value tr)(root-value (right-subtree tr))) '())))))
  </code></pre>