# Using the Range function with the Slot (#) function

I am writing a code to display longitudinal waves. I started with the following, filling the slots using the Range function.

    l = {Blue, Disk[{3 Sin[(5) t + 0.1 #] + 1.4 #, 1}, 0.5]} & /@
Range[25];
Animate[Evaluate[Graphics[l, PlotRange -> {{-4, 44}, All}]], {t, 0,
20. \[Pi]}, AnimationRate -> .3]


The slots control the x-position of the disks, as a result I get 25 disks beside each others. However, I want to obtain this single line of disks multiple times, each line under the other, as shown in the figure below. I tried to insert a new slot in the y-position of Disk function, but I do not know how to separate this new slot from the other two in the x-position, and assign it a new Range function. Can anyone help me in this please?

Clear["Global*"]

nRow = 10;

nCol = 25;

l = {Blue,
Disk[{3 Sin[5 t + 0.1 #[[1]]] + 1.4 #[[1]], 1.5 #[[2]]},
0.5]} & /@ Flatten[Array[{#1, #2} &, {nCol, nRow}], 1];

Animate[Evaluate[Graphics[l, PlotRange -> {{-4, 44}, All}]], {t, 0,
20. π}, AnimationRate -> .3]


• Thank you Bob! You are a Legend! Commented Oct 14, 2019 at 17:33

### Array:

ClearAll[disks]
disks[t_, nc_, nr_] := Array[Disk[{3 Sin[5 t + 0.1 #] + 1.4 #, 1.5 #2}, 0.5] &, {nc, nr}];

Animate[Graphics[{Blue, disks[t, 25, 10]}, PlotRange -> {{-4, 44}, All}], {t, 0, 20.  π},
AnimationRate -> .3]


### Outer:

ClearAll[disks2]
disks2[t_, nc_, nr_] := Outer[Disk[{3 Sin[5 t + 0.1 #] + 1.4 #, 1.5 #2}, 0.5] &,
Range @ nc, Range @ nr];

Animate[Graphics[{Blue, disks2[t, 25, 10]}, PlotRange -> {{-4, 44}, All}], {t, 0, 20.  π},
AnimationRate -> .3]


same picture

### Tuples:

ClearAll[disks3]
disks3[t_, nc_, nr_] := Disk[{3 Sin[5 t + 0.1 #] + 1.4 #, 1.5 #2}, 0.5] & @@@
Tuples[Range /@ {nc, nr}];

Animate[Graphics[{Blue, disks3[t, 25, 10]}, PlotRange -> {{-4, 44}, All}], {t, 0, 20. π},
AnimationRate -> .3]


same picture

ClearAll[disks4]
disks4[t_, nc_, nr_] := Disk[#, .5] & /@
Tuples[{3 Sin[5 t + 0.1 Range[nc]] + 1.4 Range[nc], 1.5 Range[nr]}]

Animate[Graphics[{Blue, disks4[t, 25, 10]}, PlotRange -> {{-4, 44}, All}], {t, 0, 20. π},
AnimationRate -> .3]
`

same picture