Hello everyone,

I would like to ask you a question, let’s imagine that we have a huffman tree below:

we want to make a recursive scala function that wants to give us the number of bits to have a letter for example to have the letter ‘A’ with the tree of huffman it is necessary to have “1 0 0” for the letter ‘o’ it is necessary ‘1 1 1 1’ and the letter ‘h’ “1 1 1 0” and so on and we would like to make that in scala, we have already programmed a little but there are errors:

```
def encodeSymbol(c: Char, h: Huffman): Option[List[Bit]] = {
(h,c) match {
case (Feuille(x,y),c) => Some(Nil)
case (Noeud(x,y,z),c) =>
if(encodeSymbol(c,y).contains(c)){
One::encodeSymbol(c,y)}
else{Zero::encodeSymbol(c,z)}
}
}
```

```
sealed trait Huffman
case class Feuille(freq: Double, c: Char) extends Huffman
case class Noeud(freq: Double, zero: Huffman, one: Huffman) extends Huffman
sealed trait Bit
case object Zero extends Bit
case object One extends Bit
```