I am starting to learn the Scala programming language. I understand some FP languages โโlike Erlang and Haskell, and I doubt the meaning of the for / yield expression, for example:
for (arg <- args) yield arg.length
This will collect an array with the length of any input argument. From what I understood, this looks like a map function in normal FP programming:
map (\a -> a * 2) [1, 2, 3] (in Haskell)
I know that the Scala library contains the scala.collection.map method, so I would like to know: is there any difference or restriction in using any style, or are they exactly the same?
source share