MathGroup Archive 2006

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

Search the Archive

Re: Variables Within Homemade Functions

  • To: mathgroup at
  • Subject: [mg69607] Re: [mg69590] Variables Within Homemade Functions
  • From: Murray Eisenberg <murray at>
  • Date: Sun, 17 Sep 2006 06:57:44 -0400 (EDT)
  • Organization: Mathematics & Statistics, Univ. of Mass./Amherst
  • References: <>
  • Reply-to: murray at

Easy: enclose your definition of the function in Module and include the 
variable(s) at issue in the first argument (a list) where the local 
variables are declared.

Gregory Lypny wrote:
> Hello everyone,
> How can I ensure that variables in my home made function do not  
> conflict with variables with the same name outside the function?  Say  
> I have a variable, t, whose value in my notebook is 17.  I've brought  
> in a function from another notebook, myFunction, that contains a  
> variable named t, and in running the function, t will take on a  
> value.  Unfortunately, both t's are the same.  Is there any way to  
> make the t within the my function a local variable just like index  
> counters in the Table and Do functions?
> Regards,
> 	Greg
> t=17
> myFunction[x_]:=(t=someOtherValue; rest of function here)

Murray Eisenberg                     murray at
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305

  • Prev by Date: Re: Calculation of a very ugly integral
  • Next by Date: Re: A new application for Mathematica
  • Previous by thread: Variables Within Homemade Functions
  • Next by thread: RE: Variables Within Homemade Functions