List(1,2,3,4..100)==> List((1,2),(2,3),(3,4)...(100,101))==>List(3,5,7,....201)
scala> x.map(x=>x,x+1).map(x=>x._1+x._2) :26: error: too many arguments (2) for method map: (f: Int => B)(implicit bf: scala.collection.generic.CanBuildFrom[List[Int],B,That])That x.map(x=>x,x+1).map(x=>x._1+x._2)
am trying to transform the 1 to 100 values but am getting the above error.Is there any issue with any the code?
your map function's return is incorrect.
try this:
input.map(x => (x,x+1)).map(x => x._1 + x._2)
Although, I don't see the need for two map functions when you can do it in one like this:
input.map(x => x + x + 1)
the above expression will also give you the same result.