Re: iterator strings as lists?
- To: mathgroup at smc.vnet.net
- Subject: [mg3528] Re: iterator strings as lists?
- From: wagner at bullwinkle.cs.Colorado.EDU (Dave Wagner)
- Date: Wed, 20 Mar 1996 02:51:32 -0500
- Organization: University of Colorado, Boulder
- Sender: owner-wri-mathgroup at wolfram.com
In article <4ifhl5$518 at ralph.vnet.net>, J.P. and/or Valerie Purswell <purswell at netplus.net> wrote: > >EX1: > >In this example, listlimits1a is a list containing 3 elements, and Mma >does not accept it as the second arguement in Table[]. When the string {i, >1,5} is just typed normally, the command executes as expected > >listlimits1a = {i, 1, 5} >>{i, 1, 5} > > >Table[i, listlimits1a] >>Table::itform: > Argument listlimits1a at position 2 > does not have the >>correct form for an iterator.Table[i, listlimits1a] This happens because Table has the HoldAll attribute. The first argument to Table must not be allowed to evaluate before the values for the iteration variable can be substituted. The workaround is to use Table[i, Evaluate[listlimits1a]]. >the difference between being able to substutite an expression for the second >arguement in Table and Take seems to be related to the fact that the Table[] >command is an iterator. Is there some (deliberate) reason for mathematica to >not accept an expression for the second argument, or was it simply not coded >that way? If the answer is (b) is there some work-around? I don't know what the design rationale for this is. It seems to me like Table could get by with the HoldFirst attribute, but maybe there's some pathological case of which we're not aware that precludes this. Dave Wagner Principia Consulting (303) 786-8371 dbwagner at princon.com http://www.princon.com/princon ==== [MESSAGE SEPARATOR] ====