I have two sets of data in two separate lists (I'm using soapui open groovy script) - which has gone through XmlSlurper().parseText() not sure if this matters
a = [c1,c2,c3]
b = [0 100, 0 50 100, 0 500 1000]
and I want to combine them (location 0 to location 0 then location 1 to location 1 etc) to be like this
c = [[c1,0 100],[c2,0 50 100],[c3,0 500 100]]
The code I have so far
def splitList(list, splitAt)
{
list.inject([]) { curr, val ->
if(curr.size() == 0 || val == splitAt)
{
curr << []
}
curr[-1] << val
curr
}
}
def c = [a, splitList(b, 0)].transpose()*.flatten()
and when I log.info c I get [[c1,0 100, 0 50 100, 0 500 100]]
Aucun commentaire:
Enregistrer un commentaire