flattenLists
Flattens a list of lists by concatenating all values from the inner lists into one list.
If an element in the outer list (the list of lists) is a single value, it is treated as an inner list of one value.
The function is not recursive. If an inner list contains a value that is itself a list, that value is not flattened.
Parameters
LIST OF LISTS (list)
A list of lists to be flattened.
Examples
ATL in Script | Input List | Flattened List | Printed Result |
---|---|---|---|
| ((1, 2), (3, 4), (5, 6)) | (1, 2, 3, 4, 5, 6) | 1, 2, 3, 4, 5 and 6 |
| (1, (2, 3), (4, 5), 6) | (1, 2, 3, 4, 5, 6) | 1, 2, 3, 4, 5 and 6 |
| (1, (2, 3, 4), (5, 6, 7)) | (1, 2, 3, 4, 5, 6, 7) | 1, 2, 3, 4, 5, 6 and 7 |
| (1, (2, (3, 4), 5, 6), 7) | (1, 2, (3, 4), 5, 6, 7) | 1, 2, 3 and 4, 5, 6 and 7 |
When an inner list contains a value that is also a list — e.g. (3,4) in the fourth example above — that value is not flattened. You can further flatten the resulting list by applying the function again:
[[flattenLists(flattenLists((1,(2,(3,4),5,6),7)))]]
Input List | Flattened List | Printed Result |
---|---|---|
(1, 2, (3, 4), 5, 6, 7) | (1, 2, 3, 4, 5, 6, 7) | 1, 2, 3, 4, 5, 6 and 7 |
The Printed Result column shows how the result is displayed in the project output. The examples assume that Studio's defaults for list formatting apply. You can change the settings at Settings > List Formatting.