Skip to content

Instantly share code, notes, and snippets.

Created June 24, 2015 10:29
What would you like to do?
Fold on Binary Tree
def fold[A, B](t:Tree[A] , z:B)(f:(B,A,B) => B): B = t match {
case EmptyTree => z
case Node(x,l,r) => f ( fold( l , z )(f) , x , fold( r , z )(f) )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment