# Add list of vectors to list of vectors recursively

This question relates to Add a vector to a list of vectors whereas here I want to add list of vectors to list of vectors recursively. Given:

m = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}
k = m

Adding each vector of m to each vector of k is done by

k = Transpose[# + Transpose[m]] & /@ k

resulting in

{{{2, 0}, {1, 1}, {0, 0}, {1, -1}}, {{1, 1}, {0, 2}, {-1, 1}, {0,0}}, {{0, 0}, {-1, 1}, {-2, 0}, {-1, -1}}, {{1, -1}, {0,0}, {-1, -1}, {0, -2}}}

This is my new k and should go back into my code, so I can add the vectors m to each element of this new k. The new result starts with {{{{3,0},{2,1},{1,0),{2,-1}}... I tried

Table[k = (Transpose[# + Transpose[m]] & /@ k), {i, 2}]

But it does not work and then I get too confused. Any idea for this tree-like structure?

## 1 Answer

This can be done with Nest and Outer. If you need intermediate results, you would use NestList:

n = 1; (*number of recursions*)
m = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
Nest[Flatten[Outer[Plus, #, m, 1], 1] &, m, n]

An for n=2: