Background
If I want wo reshape list1
as list2
:
list1 = {1, 2, 3, 4, 5, 6};
list2 = {{7, 4}, {1, 7}, {7, 6}};
We can use ArrayReshape
and Dimensions
to do it.
ArrayReshape[list1, Dimensions[list2]]
{{1, 2}, {3, 4}, {5, 6}}
Question
But when the list2
is a ragged list,how to do such thing with elegant method?
list = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
ragList = {{1, 2, 3}, {4, {5, 6}, 7}, {8}, {{{9}}, 10}};
list
to beragList
as its dimension $\endgroup$ – yode Feb 17 '17 at 21:51