I am trying to create a function in functional programming, which recieves a normal Int value and translates it to financial chinese numbers and returns a String, for exaple: 301 = 三百零一. To begin, I have two maps, one with every digit from 0 to 9, and the other one with the exponentials, from 10, to 1000000.

`val digits: Map[Int, String] = Map(0 -> "〇", 1 -> "壹", 2 -> "貳", 3 -> "參", 4 -> "肆", 5 -> "伍", 6 -> "陸", 7 -> "柒", 8 -> "捌", 9 -> "玖");`

`val exponent: Map[Int, String] = Map(1 -> "", 10 -> "拾", 100 -> "佰", 1000 -> "仟", 10000 -> "萬", 100000 -> "億", 1000000 -> "兆");`

For the ones who don´t know, here goes a little explanation about how chinese numbers work. If you already know, don´t bother in reading this paragraph. In the chinese numbers, when you want to write a large number, for example 5000, you write the 5 and the 1000 symbols (伍仟) to intimate that you are multiplying 5 \* 1000. If you have 539, it´s 5*100 + 3*10 + 9. This would be 伍佰參拾玖. Lastly, if the number has 0´s between multiplications, it doesn´t matter how many they are, you write only one 0 between the other characters. For example: 501 = 5*100 + 1. This is 伍佰〇壹. One last example for calrification: 50103 = 5*10000 + 1\*100 + 3. This is 伍萬〇壹佰〇參.

So what I could do, is the following:

```
def format(unit: Int): String = {
val l = unit.toString.map(_.asDigit).toList
if(l.isEmpty) ""
else if(l.tail.isEmpty) digits(l.head)
else digits(l.head) + format(l.tail.mkString.toInt)
}

```

This translates the characters one by one. For example:

```
format(135) "壹參伍"

```

And I don´t know how to continue.