如何在scala中配对相邻的值?

时间:2017-06-23 13:24:17

标签: scala

var sheet = SpreadsheetApp.getActive();
var name = sheet.getName();
var newName = name.slice(0,name.length-2);

我有一个上面的字符串列表

我希望输出低于

 List[String] = List(id:1, count:23331, id:3, count:34123, id:4, count:4021)

Scala代码:

 List((1,23331),(3,34123),(4,4021))

有人可以帮助我获得预期的输出

1 个答案:

答案 0 :(得分:1)

result.map(_.split(":")(1)).sliding(2,2).toList.map{case List(a,b) => (a,b)}
相关问题