Created
October 12, 2012 12:25
-
-
Save seoh/3878964 to your computer and use it in GitHub Desktop.
print CodeTree of Assignment4 (FPPiS)
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
def mkString(tree: CodeTree): String = { | |
def __mkString(tree: CodeTree, depth: Int): String = | |
List.fill(depth)('\t').mkString + "(" + chars(tree).mkString + ") " + weight(tree) + "\n" + | |
(tree match { | |
case Fork(left, right, chars, weight) => | |
__mkString(left, depth + 1) + __mkString(right, depth + 1) | |
case Leaf(chars, weight) => | |
"" | |
}) | |
__mkString(tree, 0) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
this is not SOLUTION about assignment of FPPiS. this is just utility function to helping solve an assignment.