# How can I pass in parameters for multiple controls to a function that returns a Manipulate?

For instance, I have a some "commands" that I use regularly, for example:

  Manipulate[Plot[fun, {var, ldv, udv}, PlotRange -> {{plx1, plx2}, {ply1, ply2}}],    {av , lav, avu}].


So I define a custom function to avoid all the parethesis and braces as follows:

  cman[fun_, var_, ldv_, udv_, plx1_, plx2_, ply1_, ply2_, av_, lav_, uav_ ] :=
Manipulate[Plot[fun, {var, ldv, udv}, PlotRange -> {{plx1, plx2}, {ply1, ply2}}] ,  {av , lav, uav}].


This works exactly how I want it to, for this special case. However what do we do if we have more manipulation variables. For instance I would like to similarly flatten out the following code,

  Manipulate[Plot[fun, {var, ldv, udv}, PlotRange -> {{plx1, plx2}, {ply1, ply2}}],  {av1 , lav1, uav1}, {av2 , lav2, uav2},{av3 , lav3, uav3}, ...{avn , lavn, uan}]


(of course the three dots are not really code but just their to indicate the idea that i want to be able to stack as many manipulate variables as possible).

The strategy that I came up with is as follows: I can condense the manipulation variables into one variable by starting with the , List[av1 , lav1, uav1, av2 , lav2, uav2, av3 , lav3, uav3, ...avn , lavn, uan]

Then hit the list with

   Partition[List[av1 , lav1, uav1, av2 , lav2, uav2, av3 , lav3, uav3, ...avn ,       lavn, uan],3]


Which give the list,

   {{av1 , lav1, uav1}, {av2 , lav2, uav2},{av3 , lav3, uav3}, ...{avn , lavn, uan}}.


However I can not put the code in like that so I must turn this list into a sequence, for which the following is used:

  l2s[{}] := Sequence[]; l2s[L_] := Sequence[First[L], l2s[Rest[L]]]


I then attempt to flatten my code with the following:

  Cman[fun_, var_, ldv_, udv_, plx1_, plx2_, ply1_, ply2_, L__ ] :=
Manipulate[Plot[fun, {var, ldv, udv}, PlotRange -> {{plx1, plx2}, {ply1, ply2}}],
l2s[Partition[List[L], 3]]].


This gives however gives me the following error:

Manipulate::vsform: "Manipulate argument l2s[Partition[{a,0,1},3]] does not have the correct form for a variable specification"

My question is therefore twofold: 1) is their a way to make it work through the error, since

 l2s[Partition[List[1, 2, 3, 4, 5, 6], 3]]


give the output Sequence[{1, 2, 3}, {4, 5, 6}]?

2) Is their another better way to do this?

I want to know if I can make my approach work, so I can better understand the program. For the same reason, I am also interested in better alternatives.

Note: For my practical purposes, the following code is pretty good.

  custman[fun_, var_, ldv_, udv_, plx1_, plx2_, ply1_, ply2_, L1__] :=
Manipulate[
Plot[fun, {var, ldv, udv},
PlotRange -> {{plx1, plx2}, {ply1, ply2}}], L1].


However one must use the function as follows,

 custman[a x^2 + b, x, 0, 1, 0, 1, 0, 9, {a, 0, 1}, {b, 0, 1}]


I want use the function in the following way:

 custman[a x^2 + b, x, 0, 1, 0, 1, 0, 9, a, 0, 1, b, 0, 1]

-
Try Evaluate[Sequence @@ Partition[{L1}, 3]] –  Simon Woods Nov 21 '13 at 10:56
I think one is better off writing {a, 0, 1}, {b, 0, 1},... but one is entitled to one's own taste. –  Michael E2 Nov 22 '13 at 0:48

Simon Woods, in his comment, gave you the code pattern you need. Here is an example of it applied to a somewhat simpler Manipulate. It shouldn't be too difficult to generalize.
custom[obj_, ctrls__] :=