Created
August 14, 2012 14:13
-
-
Save gclaramunt/3349643 to your computer and use it in GitHub Desktop.
Heterogeneous tree toy example
This file contains hidden or 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
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