Inputs
I have a very complicated list of list.
total_aug_rule_path_list =
[[[[['#1_0_0', '#2_0_0', '#3_0_0'], ['#1_0_1', '#2_0_1', '#3_0_1']],
[['#1_0_0', '#2_0_0', '#3_0_0'], ['#1_0_1', '#2_0_1', '#3_0_1']]],
[[['#1_1_0', '#2_1_0', '#3_1_0', '#4_1_0'],
['#1_1_1', '#2_1_1', '#3_1_1', '#4_1_1']]]]]
And i have a dictionary that has each element of the list as a key.
sym2id_dict = {
'#1_0_0': 1,
'#1_0_1': 2,
'#1_1_0': 3,
'#1_1_1': 4,
'#2_0_0': 5,
'#2_0_1': 6,
'#2_1_0': 7,
'#2_1_1': 8,
'#3_0_0': 9,
'#3_0_1': 10,
'#3_1_0': 11,
'#3_1_1': 12,
'#4_1_0': 13,
'#4_1_1': 14,}
I'm going to map each element of the list to the value of the dictionary.
output
[[[[[1, 5, 9], [2, 6, 10]], [[1, 5, 9], [2, 6, 10]]],
[[[3, 7, 11, 13], [4, 8, 12, 14]]]]]
I tried the following to use the for loop as little as possible.
list(map(lambda proofpaths_to_goal :
list(map(lambda proofpaths_to_template :
list(map(lambda proofpath :
list(map(lambda single_augment : list(map(lambda x : sym2id_dict[x], single_augment)),
proofpath)), proofpaths_to_template)), proofpaths_to_goal)),total_aug_rule_path_list))
I would appreciate it if you could let me know if there is a way that is easier or more readable than this method.