Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2001

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

Search the Archive

Re: subscripted variables in Modules

  • To: mathgroup at
  • Subject: [mg30116] Re: subscripted variables in Modules
  • From: "Orestis Vantzos" <atelesforos at>
  • Date: Sat, 28 Jul 2001 22:08:53 -0400 (EDT)
  • Organization: National Technical University of Athens, Greece
  • References: <9jtkij$89j$>
  • Sender: owner-wri-mathgroup at

If you define X as a local variable and take care to use UpSet(^=) and
UpSetDelayed(^:=) for any definitions involving Subscript[X,i] then
everything works fine.

"Arny" <someone at somewhere.sometime> wrote in message
news:9jtkij$89j$1 at
> Hello All,
> (After some effort) I have gotten a proggy with subscripted variables to
> what I want and have come to appreciate the utility of Mathematica's
> decision to not declare subscripted variables as variables but as
> expressions, i.e.
> In: FullForm[X_i]
> Out: SubScript[X,i]
> The value being that one can create formulas with subscripted variables,
> then apply replacement rules that automatically handle the iterators,
> In: Sum[X_i , {i,n} ] /. {n->Length[data], X_i -> data[[i]]}
> Out:data[[1]] + data[[2]] + data[[3]] + ... etc ...+ data[[Length[data]]]
> Ok, no problem.  However when I do my algorithm inside of a Module[] I am
> not able to declare X_i as a local variable because it isn't a variable,
> is an expression.  So long as I am not using X_i's elsewheres this is no
> problem, but of course I would like to protect everything and would like
> do so.
> Any suggestions????
> B
> --
> Bernard Gress
> Department of Economics
> University of California, Riverside
> 1150 University Ave.
> Riverside, CA 92521-0247
> Fax: (909) 787-5685
> Phone: (909) 778 9813

  • Prev by Date: Re: Pattern matching "on the fly"
  • Next by Date: Re: Pattern matching "on the fly"
  • Previous by thread: subscripted variables in Modules
  • Next by thread: AW: RE: Memory Leak