Last active
August 29, 2015 14:23
-
-
Save adilakhter/e5a2b0a5f75ee2a2f03f to your computer and use it in GitHub Desktop.
size of the tree
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
def size[T] (tree: Tree[T]) = | |
fold(tree, 0: Int){(l,x,r) => l + r + 1} | |
scala> size(t1) | |
res11: Int = 7 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment