Skip to content

Instantly share code, notes, and snippets.

@grauwoelfchen
Created June 12, 2013 18:43
Show Gist options
  • Save grauwoelfchen/5767950 to your computer and use it in GitHub Desktop.
Save grauwoelfchen/5767950 to your computer and use it in GitHub Desktop.
(define t-in-order
(lambda (t)
(if (t-empty? t)
'()
(append (t-in-order (t-left t))
(list (t-value t))
(t-in-order (t-right t)))) ))
(define t-in-order-r
(lambda (t)
(let aux ([t t] [res '()])
(if (t-empty? t)
res
(aux (t-left t)
(cons (t-value t)
(aux (t-right t) res))) ))))
(printf "in-order : ~s~n" (t-in-order my-tree))
(printf "in-order : ~s~n" (t-in-order-r my-tree))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment