Re: Constructing Expressions from List Elements

*To*: mathgroup at smc.vnet.net*Subject*: [mg2227] Re: [mg2143] Constructing Expressions from List Elements*From*: wagner at goober.cs.colorado.edu (Dave Wagner)*Date*: Tue, 17 Oct 1995 02:34:45 -0400*Organization*: University of Colorado, Boulder

In article <45d02k$5tc at ralph.vnet.net>, Lou Talman <me at talmanl.mscd.edu> wrote: >In[1]:= > q = ##& >Out[1]= > ##1 & >In[2]:= > limits = {{x, 0, 1}, {y, -Infinity, Infinity}, {z, 0, 1}} >Out[3]= > {{x, 0, 1}, {y, -Infinity, Infinity}, {z, 0, 1}} >In[4]:= > Integrate[f[x, y, z], Apply[q, limits]] >Out[5]= > Integrate[f[x, y, z], {x, 0, 1}, {y, -Infinity, Infinity}, {z, 0, 1}] > >--Lou Talman > What Lou is doing is taking a List and turning it into a Sequence. There's a more direct way to do this: Integrate[f[x, y, z], Sequence @@ limits] Another nice use of this trick is when you have a list of subscripts that you want to use as a multiple-level index into a list: s[[Sequence @@ subscripts]] Note that s[[subscripts]] behaves quite differently. You can think of Sequence@@ as an operator that obliterates the head of the expression it is applied to. Actually the head List is replaced by Sequence, which subsequently is flattened. Dave Wagner Principia Consulting (303) 786-8371 dbwagner at princon.com http://www.princon.com/princon