Exercise: Process a List of Numbers
- val xs = List(1,2,3,4)
- val ys = "1,2,3,4,"
Which snippets return true?
ys == xs.map(x => x+1)
ys == xs.map(_ + 1)
ys == xs.filter(x => x % 2)
ys == xs.filter(_ % 2 == 0)
ys == xs.fold(",")((x,y) => x.toString+y)
ys == xs.map(x => x.toString + ",").fold("")((x,y) => x+y)