Skip to content

Instantly share code, notes, and snippets.

@gclaramunt
Created August 14, 2012 14:13
Show Gist options
  • Save gclaramunt/3349643 to your computer and use it in GitHub Desktop.
Save gclaramunt/3349643 to your computer and use it in GitHub Desktop.
Heterogeneous tree toy example
trait HTree
case class HTNode[T, LT <: HTree,RT <: HTree](node:T, lt:LT, rt:RT ) extends HTree
case class HTNil() extends HTree
/*
exmaple:
scala> HTNode ( 1, HTNode("a",HTNode(1.0,HTNil(),HTNil()), HTNode('z',HTNil(),HTNil())), HTNode(List(1,2,3),HTNil(),HTNil()))
res2: HTNode[Int,HTNode[java.lang.String,HTNode[Double,HTNil,HTNil],HTNode[Char,HTNil,HTNil]],HTNode[List[Int],HTNil,HTNil]] = HTNode(1,HTNode(a,HTNode(1.0,HTNil(),HTNil()),HTNode(z,HTNil(),HTNil())),HTNode(List(1, 2, 3),HTNil(),HTNil()))
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment