# Replace iterators with slots

Still trying to understand syntax for slots... How would I use slots to do this:

a = {
{{1, 2, 3}, {4, 5, 6},    {7, 8, 9},    {10, 11, 12}},
{{2, 4, 6}, {8, 10, 12},  {14, 16, 18}, {20, 22, 24}},
{{3, 6, 9}, {12, 15, 18}, {21, 24, 27}, {30, 33, 36}}
};

Show@ListPointPlot3D[Table[a[[i, j]], {i, {1, 2, 3}}, {j, {1, 2, 3, 4}}]]


I think it should look something like this:

 Show@ListPointPlot3D[a[[#1, #2]] & /@ {{1, 2, 3}, {1, 2, 3, 4}}]


but that gives several errors which I'm not interpreting correctly so am unable to fix it. Whereas I can see how this works:

Show@ListPointPlot3D[a[[#1]] & /@ {1, 2, 3}]

• That's because Map doesn't construct the Tuples like Table does. You don't even need Slot or Map to do this, though, e.g. Show@ListPointPlot3D[Extract[a, Tuples[{{1, 2, 3}, {1, 2, 3, 4}}]]] – b3m2a1 Jan 30 at 19:28
• I don't understand. With the a you define, Show@ListPointPlot3D[ Table[a[[i, j]], {i, {1, 2, 3}}, {j, {1, 2, 3, 4}}]] is the same as ListPointPlot3D[a], so you do not need slots or a table. – bill s Jan 30 at 19:41
• I was trying to see how slots work as iterators, this probably isn't the best example though (as there is a lot of redundancy). Show@ListPointPlot3D[a[[#1]] & /@ {1, 2, 3}] works, but Show@ListPointPlot3D[a[[#1, #2]] & /@ {{1, 2, 3}, {1, 2, 3, 4}}] doesn't. I'll edit the question to show that's what I'm confused by – DrBubbles Jan 30 at 19:51

You could use Outer:
ListPointPlot3D[Outer[a[[##]] &, {1, 2, 3}, {1, 2, 3, 4}]]

For the specific example given you could also use ListPointPlot3D[Array[a[[##]] &, {3, 4}]].
Regarding ## see SlotSequence. If arguments are not neatly in order the longer form will work, here a[[#1, #2]] &.