How do you merge the indexes of two lists in Groovy?


I have two lists that I need to merge into a new list, but the new list needs to contain merged indexes of the original lists. For example:

List1 = [1, 2, 3]
List2 = [a, b, c]

I need the output to be:

finalList = [1a, 2b, 3c]

I need to be able to do this in groovy. I appreciate any help you can provide.

Assuming both lists are the same size, in Groovy 2.4+,

list1 = [1, 2, 3]
list2 = ['a', 'b', 'c']

assert ['1a', '2b', '3c'] == list1.withIndex().collect { it, index -> it + list2[index] }

Alternatively and a bit more simply in Groovy 1.5+,

assert ['1a', '2b', '3c'] == [list1, list2].transpose()*.sum()