@flatten(t:tab)
@flatten(t:tab, n:numeric)
flatten(t)
returns a new tab where where the nesting structure of
t
has been flattened. For example,
@flatten([[1, 2], [3], [[], [4, 5]]]) -> [1, 2, 3, 4, 5]
flatten(t, n)
returns a new tab where the first n
levels of nesting
have been flattened. If n == 0
, the function is the identity. If n
is strictly negative, it is equivalent to without the level argument.
@flatten([1, [2, [3, 3], 2], [[[4, 4, 4]]]], 0) -> [1, [2, [3, 3], 2], [[[4, 4, 4]]]]
@flatten([1, [2, [3, 3], 2], [[[4, 4, 4]]]], 1) -> [1, 2, [3, 3], 2, [[4, 4, 4]]]
@flatten([1, [2, [3, 3], 2], [[[4, 4, 4]]]], 2) -> [1, 2, 3, 3, 2, [4, 4, 4]]
@flatten([1, [2, [3, 3], 2], [[[4, 4, 4]]]], 3) -> [1, 2, 3, 3, 2, 4, 4, 4]
@flatten([1, [2, [3, 3], 2], [[[4, 4, 4]]]], 4) -> [1, 2, 3, 3, 2, 4, 4, 4]
@flatten([1, [2, [3, 3], 2], [[[4, 4, 4]]]], -1) -> [1, 2, 3, 3, 2, 4, 4, 4]
See also some other lisp like functions: @car, @cdr, @concat, @cons, @empty, @drop, @take.
See also Tab Manipulations @car, @cdr, @clear, @concat, @cons, @copy, @count, @dim, @domain, @drop, @empty, @find, @flatten, @gnuplot, @insert, @iota, @is_list, @is_prefix, @is_subsequence, @is_suffix, @lace, @last, @listify, @map, @max_val, @median, @member, @normalize, @occurs, @parse, @permute, @push_back, @push_front, @range, @reduce, @remove, @remove_duplicate, @replace, @reshape, @resize, @reverse, @rotate, @scan, @scramble, @size, @slice, @sort, @sputter, @stutter, @succession, @tab_history, @tab_history_date, @tab_history_rdate, @take @to_num