Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2001
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*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 smc.vnet.net
  • Subject: [mg30116] Re: subscripted variables in Modules
  • From: "Orestis Vantzos" <atelesforos at hotmail.com>
  • Date: Sat, 28 Jul 2001 22:08:53 -0400 (EDT)
  • Organization: National Technical University of Athens, Greece
  • References: <9jtkij$89j$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

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.
Orestis

"Arny" <someone at somewhere.sometime> wrote in message
news:9jtkij$89j$1 at smc.vnet.net...
> Hello All,
>
> (After some effort) I have gotten a proggy with subscripted variables to
do
> 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,
i.e.:
>
> 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,
it
> 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
to
> 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
> BGRESS at MAIL.UCR.EDU
> http://csep.ucr.edu/staff/bernard/index.htm
>
>
>




  • 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