RE: variable problems
- To: mathgroup at smc.vnet.net
- Subject: [mg9528] RE: [mg9512] variable problems
- From: jmthomas <jmthomas at cybercable.tm.fr>
- Date: Thu, 13 Nov 1997 01:39:57 -0500
- Sender: owner-wri-mathgroup at wolfram.com
What you wrote is more or less the same as:
f[aSymbol_]:=Set[aSymbol,"this value"] When you evaluate f with a
symbolic argument, this symbolic argument is then set to "this
value". From this point of view, your goal (how can I modify the
value of a parameter of a function inside the declaration of the
function) is achieved. But you get an error message if you try to
evaluate f with an argument that is not purely symbolic:
f[1] will lead to 1="this value", and generate the "cannot set to raw
object message.
You could then write:
f[aSymbol_Symbol]:=(whatever your symbol should become) and have
another definition for f, generating an error message in the case
aSymbol has been previously set to a value.
----------------------------------------------- Jean-Marie THOMAS
Conseil et Audit en Ingnierie de Calcul jmthomas at cybercable.tm.fr
www.cybercable.tm.fr/~jmthomas
-----Original Message-----
From: Manolis Tousis [SMTP:mtousis at rodopi.cc.duth.gr] To:
mathgroup at smc.vnet.net
Sent: Sunday, November 09, 1997 5:05 AM To: mathgroup at smc.vnet.net
Subject: [mg9512] variable problems
Hello,
I am I wrote a package on mathematica for strain computations and
diagrams in mechanics but I have a problem.
Does anyone know how can I modify the value of a parameter of a
function inside the declaration of the function? Here is an example:
f[x_,y_]:=Module[
{a1,a2,a3},
a1=x+y;
x=1; <------- this line causes an error message ];
Note that I could use a local variable a1 for this putting a line
a1=x;a1=1; but because of the complexity of the source code i
wrote ,
it's not possible to rewrite every line of code.
Thanks you..
If it is possible send me this answer to my email: mtousis at rodopi.cc.du
Manolis Toussis
Student of the Civil Engineer Department of Democritus University Of
Thrace.