在Mathematica中反转Flatten?

Yar*_*tov 5 wolfram-mathematica

什么是f [x _]的倒数:= Flatten [x]其中x是具有维度变暗的数组?

Mic*_*lat 16

没有内置的功能,但它与组合很容易FoldPartition:

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
Run Code Online (Sandbox Code Playgroud)