【问题标题】:Inverse of Flatten in Mathematica?Mathematica中展平的逆? 【发布时间】:2013-12-14 06:36:06 【问题描述】: f[x_]:=Flatten[x] 的倒数是什么,其中 x 是尺寸为暗淡的数组? 【问题讨论】: 标签: wolfram-mathematica 【解决方案1】: 没有内置函数,但结合Fold 和Partition 非常简单: In[47]:= x1 = RandomReal[{0, 1}, {3, 4, 5}]; In[48]:= dims = Dimensions[x1] Out[48]= {3, 4, 5} In[49]:= x2 = Fold[Partition, Flatten[x1], Most[Reverse[dims]]]; In[50]:= x1 == x2 Out[50]= True 【讨论】: 【解决方案2】: 您可能想要Partition[] 或其亲属之一。 【讨论】: