Previous Up Next

5.43.3  Flatten a list: flatten

The flatten takes a list as argument.
flatten returns a list which is the result of recursively replacing any elements that are lists by the elements, resulting in a list with no lists as elements.
Input:

flatten([[1,[2,3],4],[5,6]])

Output:

[1,2,3,4,5,6]

If the original list is a matrix, you can use the mat2list command for this (see section 5.43.45).


Previous Up Next