You are viewing a single comment's thread. Return to all comments →
This is cool but note that you are using the flatten in a way that you normally shouldn't which might confuse people from other functional languages.
flatten
This is one of the caveats of the Scala standard library (related to implicit parameters and implicit conversion)
It's better to use flatMap instead
flatMap
val p = f() val q = f() val result = (p, q).zipped flatMap (List(_, _))
Note that the final result is a collection of Chars and there's no need to call mkString on it.
result
Char
mkString
Here's my complete answer:
println { val List(p, q) = stdin.getLines.take(2).toList (p, q).zipped flatMap (List(_, _)) }
Seems like cookies are disabled on this browser, please enable them to open this website
String Mingling
You are viewing a single comment's thread. Return to all comments →
This is cool but note that you are using the
flatten
in a way that you normally shouldn't which might confuse people from other functional languages.This is one of the caveats of the Scala standard library (related to implicit parameters and implicit conversion)
It's better to use
flatMap
insteadNote that the final
result
is a collection ofChar
s and there's no need to callmkString
on it.Here's my complete answer: