Mathematica expressions and function...

Camille

Junior Member
Jul 31, 2010
2
0
0
Dear All,

I am fairly new to mathematica. I am stuck with a problem I cannot solve. I would like to call a previous equation into the function Function. If a type directly the expression or copy paste it, it works. However, when I call the expression by its name it does not.
Here is the code for a more precise explanation:

In: ll
Out: d + a x + h x^2 + b y + e x y + c z + j z^2

In: Function[##, a x + b y + c z + d + e x y + h x^2 + j z^2] & @@ {Listp}
Out: Function[{a, b, c, d, e, h, j},
a x + b y + c z + d + e x y + h x^2 + j z^2]

It works well and I can use it to generate as many equations I want by replacing the variables a,b,c,d,e,h,j.
But if I do:

In:Function[##, ll] & @@ {Listp}
Out:Function[{a, b, c, d, e, h, j}, ll]

And I cannot use it.

Any suggestions?

Thanks in advance. Do not hesitate to post if you need some further information. Sorry for my bad english.

Camille
 

donttnod

Junior Member
Mar 14, 2006
4
0
0
If you evaluate
Attributes[Function]
you will see that Function has attribute HoldAll. That means Function does not evaluate arguments in the same way that most other "usual" mathematica functions do.

You may be able to accomplish what you want by wrapping ll with Evaluate like this
Function[##, Evaluate[ll]] & @@ {Listp}

Learning the subtlties of evaluation in Mathematica can be a major hurtle.

In the future it might be easier for others to help you if you included enough code to show how ll and Listp were defined. If you don't do that then others have to try to reverse engineer your code to guess what those might be.

There are other websites that might be more appropriate for asking questions about Mathematica because many more of their viewers are using Mathematica.

And no need to apologize for your bad english, your english is much much better than my use of most other languages.