我的scala列表如下所示`输入代码
List((192.168.11.3,A,1413876302036,-,-,UP,,0.0,0.0,12,0,0,Null0,UP,0,0,4294967295,other), (192.168.11.3,A,1413876302036,-,-,UP,,0.0,0.0,8,0,0,C,DOWN,0,0,100000000,P), (192.168.1.1,A,1413876001775,-,-,UP,,0.0,0.0,12,0,0,E,UP,0,0,4294967295,other), (192.168.1.1,A,1413876001775,-,-,UP,,0.0,0.0,8,0,0,F,DOWN,0,0,100000000,E))
现在我想要以下操作,在列表中第三个参数在上面改变是1413876302036和1413876001775.我想减去这个如下
val sub = ((192.168.11.3,A,(1413876302036-1413876001775),-,-,UP,,0.0,0.0,12,0,0,Null0,UP,0,0,4294967295,other),(192.168.1.1,A,(1413876001775-1413876001775),-,-,UP,,0.0,0.0,12,0,0,E,UP,0,0,4294967295,other))
如何在scala中计算
答案 0 :(得分:0)
在读完你的问题15分钟后,我想我仍然不理解,但如果我这样做是一个答案:
val list = List(("192.168.11.3",'A',1413876302036l,0,0,0), ("192.168.11.3",'A',1413876302036l,0,0,0),
("192.168.1.1",'A',1413876001775l,0,0,0), ("192.168.1.1",'A',1413876001775l,0,0,0))
val newList = list map { _ match {
case (a,b,value,c,d,e) => (a,b,value-1413876001775l,c,d,e)
}}
我允许自己稍微重写一下你的例子。下次尝试保持简单并使用SSCCE rules