I encountered real problem at first, and here is the toy example
variable argument
stored some expression that is generated from other parts of the program. I suppose it's content is {xx, yy, zz}
argument = {xx, yy, zz}
and define a function test
test[argument_,t_] := {argument^2, Range[t]}
test
function has only t
as variable. Because when I use test
, I don't need to substitute values into xx,yy,zz
, I just manipulate expression stored in argument.
Now I want to define another function that has full control of xx,yy,zz,t
in test
function in order to get numerical results.
So I tried
f[xx_,yy_,xx_, t_] := test[t]
This won't work, because test[t]
is hold. f[1,1,1,1]
will give
{{xx^2, yy^2, zz^2}, {1}}
and this won't work either
f[xx_,yy_,xx_, t_] := Evaluate@test[t]
Though Evaluate
unhold argument
, while Range[t]
can't be evaluated with letter t at the first step. So it will give errors like
Range::range: Range specification in Range[t] does not have appropriate bounds. >>
So how to do it?
ps:
For this simple case, surely I could directly define in this way.
f[xx_, yy_, zz_, t_] := test[{xx, yy, zz}, t];
But this is not what I want. As I said, the argument
is dynamically generated by other parts of the program, so we cannot use its explicit form.
kx
andxx
(and the same foryy
andzz
)? $\endgroup$test[t_]:= f[xx,yy,zz,t]
$\endgroup$argument
is dynamically generated by other part of the program in my real case, not like{xx,yy,zz}
this simple. $\endgroup$f[xx,yy,zz,t]
you want it to modify the value ofargument
? $\endgroup$