Groovy zipping lists or flattening by level
flatten, groovy, list
Solution
[a, b].transpose().collectMany { it }
Problem
I am trying to zip two lists. I found a solution using `transpose` (from this link: Is there any analog for Scala 'zip' function in Groovy?) but the result is not quite what I expected. I want to have lists zipped! I really mean zipped. Given: ``` a = [ [1,2,3] , [4,5,6], [7,8,9] ] b = [ ['a','b','c'] , ['d','e','f'], ['g','h','j']] ``` Expected result: ``` zipped = [ [1,2,3], ['a','b','c'], [4,5,6], ['d','e','f'], (...) ] ``` But transpose gives me: ``` [a,b].transpose() = [ [[1,2,3],['a','b','c']] [[4,5,6],['d','e','f']] [[7,8,9],['g','h','j']] ] ``` I tried to somehow flatten the last list but there is no flattenning by level. Every single list is being flatten where I want just to get out of the "rows" lists,