# Copy Form of list

I have a list like this for exmple:

{{{1,2},{3,4}},{{1,2}},{{1,2},{3,4},{5,6}}}

So now i have to copy the form of the list with oen depth less so my result would be :

{{0,0},{0},{0,0,0}}

The first list might be a millions of points long so it should be kinda time efficient. Any Ideas would be great, Thanks in advance

• While you wait for a fast answer have a play around with {{{1, 2}, {3, 4}}, {{1, 2}}, {{1, 2}, {3, 4}, {5, 6}}} /. {__Integer} -> 0 Dec 3, 2019 at 19:44
• Will it always be a 3D list where each element is a list of pairs? Or are there other possibilities? Replace[yourlist, {_, _} -> 0, {2}] yields the correct result, but it may not cover all the possible kinds of lists you need to deal with. Dec 3, 2019 at 19:50
• Yeah, it will always be 3D Dec 3, 2019 at 20:03

## 2 Answers

  list = {{{1, 2}, {3, 4}}, {{1, 2}}, {{1, 2}, {3, 4}, {5, 6}}};

Total[list 0, {3}]


Or

Apply[Total, list 0, {2}]


Or

ConstantArray[0, #] & /@ Length /@ list


{{0, 0}, {0}, {0, 0, 0}}

Map[0 &, list, {2}]


{{0, 0}, {0}, {0, 0, 0}}

Also

list /. _?VectorQ -> 0


{{0, 0}, {0}, {0, 0, 0}}