2
$\begingroup$

I am trying to achieve the functionality of the following command:

Manipulate[ z, {z, 0, 1}]

but with passing the list of parameters into Manipulate from and external list, e.g.

list = {z, 0, 1};
Manipulate[ z, list ]

but with this syntax I recieve the following error:

Manipulate::vsform: "Manipulate argument \!\(ToExpression[{\"z\", 0, 1}]\) does not have the correct form for a variable specification"

How can I overcome this?

$\endgroup$
0

2 Answers 2

4
$\begingroup$
list = {z, 0, 1};
Manipulate[z, Evaluate@list]

enter image description here

Manipulate has attribute HoldAll,

Attributes[Manipulate]
{HoldAll, Protected, ReadProtected}

i.e.

all arguments to a function are to be maintained in an unevaluated form

Using Evaluate@list makes Manipulate see {z,0,1} rather than the symbol list.

$\endgroup$
1
$\begingroup$

In addition to what kguler has said, you can also inject with With:

With[{l = list}, Manipulate[z, l] ]

or

Manipulate[z, #] &[list]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.