dimanche 2 novembre 2014

Scala: How to create a new list from operation on adjacent elements of a list


Vote count:

0




If I have a list like List(1,2,3,4), I want to create a new list that will be equivalent to,


List(1+2, 3+4) = List(3,7)


I need some opeartion to add adjacent numbers in a list and create new list from it. I looked at map, reduceLeft, foldLeft operations but could not find something that would accomplish this.



asked 1 min ago







Scala: How to create a new list from operation on adjacent elements of a list

Aucun commentaire:

Enregistrer un commentaire