I have a list of sublist and want to reverse some pairs of this list. I want to find a way to define the pairs that should be reversed based on my data. This is list of pairs:
split_list=[[[4, 1], [3, 0], [2, 3], [0, 3], [2, 1], [1, 4]],\
[[3, 1], [2, 1], [1, 0], [1, 1]]]
It has two sublists. Then I have the data that I want o use them to find where I should reverse the pairs:
chunk_len=[[np.array([[1., 2.]]), np.array([[1., 2.], [3., 4.]]), np.array([[0., 0.]])],\
[np.array([[1., 2.]]), np.array([[1., 2.]])]]
I want to find the pairs that should be reversed based on the lengths of sublists stored in chunk_len. Length of first sublist in chunk_len is 3. Based on this length, first sublist of split_list should be divided into 3 chunks. Then, I want to reverse the pairs that are in even chunks. For second sublist, it has 2 chunks and I want to reverse the pairs of second one. Finally I want to have it as:
[[[4, 1], [3, 0], [3, 2], [3, 0], [2, 1], [1, 4]],\
[[3, 1], [2, 1], [0, 1], [1, 1]]]
I tried the following but It was not sucessfull at all:
cor_spl=[]
for i,j in zip (split_list, chunk_len):
for m in i:
cor_spl.append(m)
if m in i[len(j):int (len(j)+len(i))]:
cor_spl.append (m[::-1])
In advance, I do appreciate any help.
chunk_len, say how to decode the information in there. Can you explain it more clearly?chunk_lendefines the number of existing chunks in the same sublist ofsplit_listThen, I wan to reverse even chunks.