I have jumped into Scala and started doing scala99, but I am stuck at P07 (flattening of list) following is my code and error message from the repl
scala> def flatten[A](x: List[A]): List[A] =
| for(i <- x) yield i match {
| case lst: List[Any] => flatten(lst)
| case e => List(e)
| }
<console>:12: error: type mismatch;
found : List[List[Any]]
required: List[A]
for(i <- x) yield i match {
^
Where am I wrong and what is the correct way? Thanks.