Scala list find and substraction -
Scala list find and substraction -
my scala list below `enter code here
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))
now want next operation, in list 3rd parameter changed in above 1413876302036 , 1413876001775. want subtracts below
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))
how should calculate in scala
after 15 minutes of reading question, think still don't understand it, if here answer:
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) }}
i allowed myself rewrite illustration little. next time seek maintain simple , go sscce rules
scala
Comments
Post a Comment