Given an arbitrarily nested empty matrix like for example
mat =
{
{},
{{}, {}},
{{}, {{}}, {}},
{{}, {{}}, {}, {{{}}}}
};
and knowing that
Depth /@ mat
{2, 3, 4, 5}
Question 1
how can I produce the following result?
res =
{
{2},
{{3}, {3}},
{{3}, {{4}}, {3}},
{{3}, {{4}}, {3}, {{{5}}}}
};
Question 2
Given
{{2}, {3, 3}, {3, 4, 3}, {3, 4, 3, 5}};
how can I produce the above empty matrix mat
?