I want to change the slot number inside Manipulate[]. Here is a minimal example which does not work:
Manipulate[Sin[#n] & [0, Pi/2], {n, Range[2]}]
I expect an output of 0 when n=1 and 1 when n=2 (sine evaluated at n-th argument).
I've also tried Slot[n], # n but they do not work either. I couldn't find any similar question.
How would you make it?
EDIT 1
Kuba's answer
Manipulate[Evaluate@Sin[Slot[n]] &[0, Pi/2], {{n, 1}, Range[2]}]
works for the minimal example. In my case i use it while plotting graphics:
Manipulate[
Module[{min, max, col},
{min, max} = Through@{Min, Max}@pointslf[1][[All, n]];
col = {"TemperatureMap", {min, max}};
Graphics3D[{ColorData[col][#6], PointSize[Large],
Point[{#1, #2, #3}]} & @@@ pointslf[1]]
],
{n, Range[6, 7]}
]
If i substitute #6 with Evaluate@Slot[n] it doesn't work anymore. pointslf[1] is a matrix with coordinates (first three columns) and other stuff (next columns) i use to define the color.
How should i do it in this case?
Manipulate[ Sin[# n] & /@ {0, Pi/2}, {n, Range[2]} ]– Nasser Mar 24 '15 at 09:12Manipulate[ sel = {0, Pi/2}; Sin[sel[[n]]], {n, Range[2]} ]– Nasser Mar 24 '15 at 09:23