Last active
October 6, 2015 23:47
-
-
Save vasily-kirichenko/3072183 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 BinaryTree = | |
|Node of obj * BinaryTree * BinaryTree | |
|Empty | |
member tree.Traverse f = | |
match tree with | |
|Node(data, l, r) -> | |
f data | |
l.Traverse f | |
r.Traverse f | |
|Empty -> () | |
let tree = Node("Node 1", Node("Node 2", Empty, Empty), Empty) | |
tree.Traverse (printfn "%A") | |
> | |
"Node 1" | |
"Node 2" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment