Re: Subscripted local variables in Module
- To: mathgroup at smc.vnet.net
- Subject: [mg24017] Re: [mg24003] Subscripted local variables in Module
- From: BobHanlon at aol.com
- Date: Tue, 20 Jun 2000 03:07:33 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
In a message dated 6/19/2000 1:59:55 AM, skker at skker.com writes: >Why can't I use subscripted local variables in a Module? > >Module[{x[1], x[2]}, > x[1] = 1; > x[2] = 2; > x[1] + x[2] > ] >doesn't work. I could fix this code by replacing x[1] by x and x[2] by >y. But there is a more serious problem when I want a non-fixed number of >local variables. > You should have received an error message stating that x[1] and x[2] are not symbols. Believe the error message. Module[{x}, x[1] = 1; x[2] = 2; x[1] + x[2] ] 3 P.S. x[1] and x[2] are not subscripted. You have defined a discrete function. Bob Hanlon