Warning : At least in my PC (windows 10, mathematica V12.2), some of the codes here led to fatal error.
Fatal means mathematica will freeze + 'Abort Evaluation' will not work. I had to quit the kernel and lose everything.
So save every working .nb files and then try this.
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
This post is related with previous post Extracting list structure from nested list
The answerer "kglr" emphasized that
Note: Internal`CopyListStructure[arg1_, arg2_] requires Length[Flatten@arg1] == Length @ arg2
But what if Length of Flatten@arg1 are arg2 different?
In[1] Internal`CopyListStructure[{{a, {b, {{{{{c}}}}, d}}}}, {1, 2, 3, 4}]
Out[1] {{1, {2, {{{{{3}}}}, 4}}}}
(** standard case, works OK **)
In[2] Internal`CopyListStructure[{{a, {b, {{{{{c}}}}, d}}}}, {1, 2, 3, 4, 5}]
Out[2] Internal`CopyListStructure[{{a, {b, {{{{{c}}}}, d}}}}, {1, 2, 3, 4, 5}]
(** arg2 is longer case : Does nothing - Parrots back what I say. **)
In[3] Internal`CopyListStructure[{{a, {b, {{{{{c}}}}, d}}}}, {1, 2, 3}]
Out[3] {{1, {2, {{{{{3}}}}, d}}}}
(** Flatten@arg1 is longer case : Does as much as one can. **)
In[4] Internal`CopyListStructure[{{a, {b, {{{{{c}}}}, d}}}}, {1, 2}]
Out[4]
(** Flatten@arg1 is longer case : But this time, fatal error**)
In[5] Internal`CopyListStructure[{{a, {b, {{{{{c}}}}, d}}}}, {1}]
Out[5]
(** Flatten@arg1 is longer case : But this time, fatal error**)
I want to know that you(your PC) are having the same trouble.
I think there is a workaround but why does mathematica produces such fatal errors when Flatten@arg1 is longer?
Don't you think this is a bug?