In [1]:
from ahh import ext
In [2]:
list_in_list = [[1, 2, 3, 4]]
ext.flatten(list_in_list) # remove extra layer of list
# equivalent to:
list_in_list[0]
Out[2]:
Out[2]:
In [3]:
lists_in_list = [[1, 2, 3, 4], [4, 5]]
ext.flatten(lists_in_list) # but most useful if you want to remove extra layer and combine the lists within
Out[3]:
In [4]:
lists_in_list = [[2, 3, 4], [4, 5], [4, 4], [235], [231], [111]]
ext.flatten(lists_in_list) # just another example
Out[4]:
In [5]:
lists_in_list = [0, 0, 1, 1, 1, 0, 0, 0, 0, 1, 0]
ext.split_consec(lists_in_list) # break list into sections where consecutive
Out[5]:
In [6]:
lists_in_list = [3, 3, 4, 4, 4, 5, 5, 5, 5, 2, 2]
ext.split_consec(lists_in_list) # another example
Out[6]:
In [ ]: