Type mismatch in Scala's for-comprehension
Type mismatch in Scala's for-comprehension I have tried to define a recursive Scala function that looks something like this: def doSomething: (List[List[(Int, Int)]], List[(Int, Int)], Int, Int) => List[Int] = (als, rs, d, n) => if (n == 0) { for (entry <- rs if (entry._1 == d)) yield entry._2 } else { for (entry <- rs; adj <- als(entry._1)) yield doSomething(als, rs.::((adj._1, adj._2 + entry._2)), d, n - 1) } Now, the compiler tells me: | | | | | | <console>:17: error: type mismatch; found : List[List[Int]] required: List[Int] for (entry <- rs; adj <- als(entry._1)) yield doSomething(als, rs.::((adj._1, adj._2 + entry._2)), d, n - 1) ^ | | | | | | <console>:17: error: type mismatch; found : List[List[Int]] required: List[Int] for (entry <- rs; adj <- als(entry._1)) yield doSomet...