Flatten
Flatten[list]
flattens out lists in list
.
Attributes[Flatten] := {Protected}
Simple examples
In[1]:= Flatten[1]
Out[1]= Flatten[1]
Input must be nonatomic:
In[2]:= Flatten[{1}]
Out[2]= {1}
In[3]:= Flatten[{{{{1}}}}]
Out[3]= {1}
In[4]:= Flatten[{{{{1}, 2}}, 3}]
Out[4]= {1, 2, 3}
In[5]:= Flatten[{{{{1}, 2}}, 3, 4}]
Out[5]= {1, 2, 3, 4}
In[6]:= Flatten[{-1, {{{1}, 2}}, 3, 4}]
Out[6]= {-1, 1, 2, 3, 4}
A level of zero means no change:
In[7]:= Flatten[{-1, {{{1}, 2}}, 3, 4}, 0]
Out[7]= {-1, {{{1}, 2}}, 3, 4}
In[8]:= Flatten[{-1, {{{1}, 2}}, 3, 4}, 1]
Out[8]= {-1, {{1}, 2}, 3, 4}
In[9]:= Flatten[{-1, {{{1}, 2}}, 3, 4}, 2]
Out[9]= {-1, {1}, 2, 3, 4}
In[10]:= Flatten[{-1, {{{1}, 2}}, 3, 4}, 3]
Out[10]= {-1, 1, 2, 3, 4}
In[11]:= Flatten[{-1, {{{1}, 2}}, 3, 4}, 4]
Out[11]= {-1, 1, 2, 3, 4}
In[12]:= Flatten[{-1, {{{1}, 2}}, 3, 4}, a]
Out[12]= Flatten[{-1, {{{1}, 2}}, 3, 4}, a]
In[13]:= Flatten[{-1, {foo[{{1}, 2}]}, 3, 4}, 999]
Out[13]= {-1, foo[{{1}, 2}], 3, 4}
In[14]:= Flatten[{-1, {foo[{{1}, 2}]}, 3, 4}, 999]
Out[14]= {-1, foo[{{1}, 2}], 3, 4}
In[15]:= Flatten[{-1, {1[{{1}, 2}]}, 3, 4}, 999]
Out[15]= {-1, 1[{{1}, 2}], 3, 4}