I wonder if is possible flatten a list at the last level without flattening at the first level, I think that isn't a good explanation so here is my code
Table[Table[{Position[points[dx, dy, n], {i, j}][[1]],
Position[points[dx, dy, n], Vec[dx, dy, n, i, j][[k]]][[1]]}, {k,
1, Dimensions[Vec[dx, dy, n, i, j]][[1]]}], {j, -n, n}, {i, -n, n}]
This input gives me
{{{{{1}, {4}}, {{1}, {2}}}, {{{4}, {1}}, {{4}, {7}}, {{4}, {5}}},
{{{7}, {4}}, {{7}, {8}}}}, {{{{2}, {5}}, {{2}, {1}}, {{2}, {3}}},
{{{5}, {2}}, {{5}, {8}}, {{5}, {4}}, {{5}, {6}}}, {{{8}, {5}}, {{8},
{7}}, {{8}, {9}}}}, {{{{3}, {6}}, {{3}, {2}}}, {{{6}, {3}}, {{6},
{9}}, {{6}, {5}}}, {{{9}, {6}}, {{9}, {8}}}}}
If I do this I get the desired result
Flatten[Table[
Table[Flatten[{Position[points[dx, dy, n], {i, j}][[1]],
Position[points[dx, dy, n], Vec[dx, dy, n, i, j][[k]]][[1]]},
1], {k, 1, Dimensions[Vec[dx, dy, n, i, j]][[1]]}], {j, -n,
n}, {i, -n, n}], 2]
Which is
{{1, 4}, {1, 2}, {4, 1}, {4, 7}, {4, 5}, {7, 4}, {7, 8}, {2, 5}, {2,
1}, {2, 3}, {5, 2}, {5, 8}, {5, 4}, {5, 6}, {8, 5}, {8, 7}, {8,
9}, {3, 6}, {3, 2}, {6, 3}, {6, 9}, {6, 5}, {9, 6}, {9, 8}}
My question is if there is a way to do this without using Flatten twice.
I hope I explained it well.
Position[…][[1,1]]. Then you only need one a simpleFlattenfor the outer lists. – Lukas Lang Aug 07 '18 at 15:08Flattenthere isLevel[data, {3}][[All, All, 1]]– Coolwater Aug 07 '18 at 17:54