Advertisement
Guest User

Untitled

a guest
Sep 16th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.38 KB | None | 0 0
  1. def getCharCode(tree: HuffmanCodingTree, code: List[Int]): (Char, List[Int]) = (tree, code) match {
  2.     case (tr, x :: xs) if tr.chars.length == 1 => (tr.chars.head, xs)
  3.     case (tr, x :: xs) if x == 0 => getCharCode(tr.asInstanceOf[HuffmanCodingTreeNonLeaf].leftChild, xs)
  4.     case (tr, x :: xs) if x == 1 => getCharCode(tr.asInstanceOf[HuffmanCodingTreeNonLeaf].leftChild, xs)
  5.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement