Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #15319 > unrolled thread

Re: How to remove external parentheses from a list

Started byBob Hanlon <hanlonr357@gmail.com>
First post2013-08-17 05:59 +0000
Last post2013-08-17 05:59 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.soft-sys.math.mathematica

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: How to remove external parentheses from a list Bob Hanlon <hanlonr357@gmail.com> - 2013-08-17 05:59 +0000

#15319 — Re: How to remove external parentheses from a list

FromBob Hanlon <hanlonr357@gmail.com>
Date2013-08-17 05:59 +0000
SubjectRe: How to remove external parentheses from a list
Message-ID<kun3ga$3n1$1@smc.vnet.net>
Use Sequence


limits = {{x1, a, b}, {x2, c, d}, {xn, y, z}};


Integrate[f[x1, x2, xn], Sequence @@ limits]


Integrate[f[x1, x2, xn],
   {x1, a, b}, {x2, c, d},
   {xn, y, z}]


However, Mathematica only accepts this form because Integrate does not have
the Attribute HoldAll or HoldRest.

Attributes[Integrate]


{Protected, ReadProtected}


For functions that have either of these attributes, you would also need to
use Evaluate.


Attributes[Table]


{HoldAll, Protected}


limits = {{x1, 0, 1}, {x2, 0, 1}, {xn, 0, 1}};


Table[f[x1, x2, xn], Evaluate[Sequence @@ limits]] // Flatten


{f[0, 0, 0], f[0, 0, 1], f[0, 1, 0], f[0, 1, 1], f[1, 0, 0], f[1, 0, 1],
 f[1, 1, 0], f[1, 1, 1]}



Bob Hanlon


On Fri, Aug 16, 2013 at 7:06 AM, Samuel Mark Young <sy81@sussex.ac.uk>wrote:

>
> Hello,
>
> I'm looking for an easy way to remove the external parentheses from a
> list.  The list contains integration variables and their respective limits,
> it currently looks something like this:
>
> {{x1,a,b},{x2,c,d},...,{xn,y,z}}
>
> However, the Integrate (or NIntegrate function) in Mathematica wants me to
> write it like this:
>
> {x1,a,b},{x2,c,d},...,{xn,y,z}
> i.e. The external parentheses have been removed
>
> I've looked around online and seen suggestions for replacing the curly
> brackets "{" with a blank space " ", or using Apply (@@) but can't work out
> the correct syntax.
>
> Thanks for any help and advice!
>
> Regards,
> Sam
>
>
>

[toc] | [standalone]


Back to top | Article view | comp.soft-sys.math.mathematica


csiph-web