Bug introduced in 8.0.4 or earlier and persisting through 11.0.1
First of all, please look at the below inputs and outputs:
In[1]:= $a = Array[# Range[#] &, {5}]
Out[1]= {{1}, {2, 4}, {3, 6, 9}, {4, 8, 12, 16}, {5, 10, 15, 20, 25}}
In[2]:= $af = Flatten[$a, {{1}, {2}}]
Out[2]= {{1}, {2, 4}, {3, 6, 9}, {4, 8, 12, 16}, {5, 10, 15, 20, 25}}
In[3]:= $a === $af
Out[3]= True
In[4]:= FullForm[$a] === FullForm[$af]
Out[4]= True
In[5]:= TreeForm[$a]
Out[5]:=
In[6]:= TreeForm[$af]
Out[6]:=
In[7]:= TreeForm[$a] === TreeForm[$af]
Out[7]= True
Then, I have natural questions:
Why are there the differences between the output of TreeForm[$a]
and that of TreeForm[$af]
? What makes these differences? Though Mathematica says "True"s for the checking equalities.
TreeForm[Array[ # Range[#] &, {5}]]
, the first one, is clearly wrong. Also, the output ofTreeForm@Array[Range[#] &, {5}]
is even weirder... $\endgroup$TreeForm
will fail on arrays where the sublists are packed. Compare the output ofDeveloper`PackedArrayQ /@ a
andDeveloper`PackedArrayQ /@ $af
. A workaround is to unpack the subarrays,TreeForm[$a /. {x_?Developer`PackedArrayQ :> Developer`FromPackedArray[x]}]
$\endgroup$