Advertisement
valtih1978

for-comprehension produces Seq instead of List

Jun 27th, 2014
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scala 0.39 KB | None | 0 0
  1.   type Occurrences = List[(Char, Int)]
  2.  
  3.     def expand(acc: List[Occurrences], occurrence: (Char, Int)): List[Occurrences] = occurrence match {
  4.       case (c, int) => (for (i <- (0 to int) ; ao <- acc) yield ((c, i) :: ao)).toList
  5.     }                                          
  6.  
  7. // I have to use toList yet result is empty anyway
  8.  
  9. expand(List[Occurrences](), ('a' ,3))         //> List()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement