Skip to content

Instantly share code, notes, and snippets.

@adilakhter
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adilakhter/e5a2b0a5f75ee2a2f03f to your computer and use it in GitHub Desktop.
Save adilakhter/e5a2b0a5f75ee2a2f03f to your computer and use it in GitHub Desktop.
size of the tree
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