So, considering:
List l1 = ['A', 'B', 'C', 'D', 'E']
List l2 = ['a', 'b', 'c', 'd', 'e']
List l3 = ['1', '2', '3', '4', '5']
List screen = [ l1, l2, l3 ]
To repeat all the elements you can do:
3.times { y ->
5.times { x ->
println screen[ y ][ x ]
}
}
Or, you can use modand intdivto develop positions of x and y:
15.times { p ->
def x = p % 5
def y = p.intdiv( 5 )
println screen[ y ][ x ]
}
Or, if you need the first item from each sub-list, you can do:
println screen*.head()
, , -:
println screen*.getAt( 2 )
:
def inlineScreen = [ *l1, *l2, *l3 ]
:
15.times { p ->
println inlineScreen[ p ]
}
def x = 1, y = 1
println inlineScreen[ x + y * 5 ]
, , (.. , ), :
// groupedScreen == [['A', 'a', '1'], ['B', 'b', '2'], ['C', 'c', '3'], ['D', 'd', '4'], ['E', 'e', '5']]
def groupedScreen = [ l1, l2, l3 ].transpose()
, 3- , :
groupedScreen[ 2 ]