You are viewing a single comment's thread. Return to all comments →
Using list comprehension in Haskell
mingle :: String -> String -> String
mingle a b = concat [[x, y] | (x, y) <- zip a b]
Thinking along the same lines here with Scala:
val List(p, q) = stdin.getLines.take(2).toList
(p, q).zipped flatMap (List(_, _))
But I still like the Haskell solution better. Comprehensions are much more intiuitive in Haskell. Comprehensions in Scala are type-homogenous, Scala 3 will hopefully take care of this. This is a topic for somewhere else though.