Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1995
*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 1995

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

Search the Archive

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


  • Prev by Date: RE: C++
  • Next by Date: Re: Help on use of Packages
  • Previous by thread: Re: Constructing Expressions from List Elements
  • Next by thread: Re: Re: Constructing Expressions from List Elements