Reputation: 566
Here's what I'm trying to do:
val StringSpace = charList.reduce(_ + _ + _ + _ + " ")
val StringList = //Tokenize StringSpace with " "
but it returns missing parameter type within first line.
So how can someone actually join lists into half or quarter size in scala?
e.g: From
List ("a" , "b" , "c" , "d" , "e" , "f" , "g" , "h")
To:
List("abcd", "efgh")
Upvotes: 0
Views: 659
Reputation: 68640
val l = List ("a" , "b" , "c" , "d" , "e" , "f" , "g" , "h")
l.grouped(4).map(_.mkString)
Upvotes: 3