MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Assign variables to a module

  • To: mathgroup at smc.vnet.net
  • Subject: [mg83559] Re: Assign variables to a module
  • From: Jens-Peer Kuska <kuska at informatik.uni-leipzig.de>
  • Date: Thu, 22 Nov 2007 06:40:49 -0500 (EST)
  • Organization: Uni Leipzig
  • References: <fi3jbg$b0c$1@smc.vnet.net>
  • Reply-to: kuska at informatik.uni-leipzig.de

Hi,

in

Test[c_,x_, y_, f_] := ...

x is *not* a variable, it is a pattern named x and it would be
a desaster if the pattern would mixed with a global variable.

You mean

f = x + y;
Test[c_, x1_, y1_, f_] := Block[{x = x1, y = y1, result},
   result = c*f;
   (*do something using f*)
   result]

Regards
   Jens

Frank Deicke wrote:
> Hello,
> I want to assign different variables to a module. One variable could be 
> a term. Now it could be possible, that the term includes the same 
> variables like I want to assign to the module. Please look at the simple 
>   example below.
> 
> IN:
> f = x + y;
> Test[c_,x_, y_, f_] := Module[
>      {result},
>      result = c*f;(*do something using f*)
>      result
>      ]
> Test[1,1,1,f]
> 
> Out:
> x+y
> 
> Is there any possibility that within the module, the variables x and y 
> of f could be replaced by the values assigned to the module (x_,y_)? 
> Finally, the result should be 2 and not x+y.
> 
> Thanks,
> Frank
> 


  • Prev by Date: Re: negative FileByteCount
  • Next by Date: Re: Dynamic Timeout
  • Previous by thread: Assign variables to a module
  • Next by thread: Problems with Mathematica text in email