Created
December 18, 2011 20:13
-
-
Save gnuvince/1494316 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type 'a tree = | |
| Empty | |
| Node of ('a * 'a tree * 'a tree) | |
let rec walk_tree f tree = | |
match tree with | |
| Empty -> () | |
| Node (x, left, right) -> | |
f x; | |
walk_tree f left; | |
walk_tree f right | |
let tree = | |
Node (4, | |
Node (2, | |
Node (1, Empty, Empty), | |
Node (3, Empty, Empty)), | |
Node (6, | |
Node (5, Empty, Empty), | |
Empty) | |
) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment