Skip to content

Instantly share code, notes, and snippets.

@bkyrlach
Created August 14, 2012 02:46
Show Gist options
  • Select an option

  • Save bkyrlach/3345897 to your computer and use it in GitHub Desktop.

Select an option

Save bkyrlach/3345897 to your computer and use it in GitHub Desktop.
ADT Tree
abstract class Tree[A]
case class Leaf[A](a: A) extends Tree[A]
case class Branch[A](left: Tree[A], right: Tree[A]) extends Tree[A]
object TreeTest extends App {
val t1 = Branch(Branch(Leaf(1), Leaf(2)), Leaf(3))
println(t1)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment