Is there a scala list operation that makes tuples from lists?

前端 未结 3 1722
我寻月下人不归
我寻月下人不归 2020-12-19 09:07

I\'m trying to process triplets in a list. Imperatively, I could do this:

for(i = 1; i < list.length-1; i++)
{
   process( list[i-1], list[i], list[i+1]          


        
3条回答
  •  情深已故
    2020-12-19 09:43

    I know you got the answer you wanted, but the technically correct answer is no. There's no general method that takes a list and returns tuples of variable arity because there's no way to represent that type signature in Scala at the present.

提交回复
热议问题