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


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

How to remove external parentheses from a list

Started bySamuel Mark Young <sy81@sussex.ac.uk>
First post2013-08-16 10:53 +0000
Last post2013-08-17 06:01 +0000
Articles 4 — 3 participants

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


Contents

  How to remove external parentheses from a list Samuel Mark Young <sy81@sussex.ac.uk> - 2013-08-16 10:53 +0000
    Re: How to remove external parentheses from a list Joe Gwinn <joegwinn@comcast.net> - 2013-08-17 05:57 +0000
      Re: How to remove external parentheses from a list Joe Gwinn <joegwinn@comcast.net> - 2013-08-20 11:36 +0000
    Re: How to remove external parentheses from a list David Bailey <dave@removedbailey.co.uk> - 2013-08-17 06:01 +0000

#15309 — How to remove external parentheses from a list

FromSamuel Mark Young <sy81@sussex.ac.uk>
Date2013-08-16 10:53 +0000
SubjectHow to remove external parentheses from a list
Message-ID<kul0bk$rkj$1@smc.vnet.net>
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] | [next] | [standalone]


#15313

FromJoe Gwinn <joegwinn@comcast.net>
Date2013-08-17 05:57 +0000
Message-ID<kun3ch$3m6$1@smc.vnet.net>
In reply to#15309
In article <kul0bk$rkj$1@smc.vnet.net>, 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.

I use Apply, as in the following, where Xcd is some function:

Apply[Xcd[#]&, {{x1,a,b}, {x2,c,d}, {xn,y,z}} ]

Depending the function you are using, you may need to use such things
as #[[1]] as variables.  Read the docs on "pure functions".

Joe Gwinn

[toc] | [prev] | [next] | [standalone]


#15327

FromJoe Gwinn <joegwinn@comcast.net>
Date2013-08-20 11:36 +0000
Message-ID<kuvkb0$mp7$1@smc.vnet.net>
In reply to#15313
In article <kun3ch$3m6$1@smc.vnet.net>, Joe Gwinn
<joegwinn@comcast.net> wrote:

> In article <kul0bk$rkj$1@smc.vnet.net>, 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.
> 
> I use Apply, as in the following, where Xcd is some function:
> 
> Apply[Xcd[#]&, {{x1,a,b}, {x2,c,d}, {xn,y,z}} ]
> 
> Depending the function you are using, you may need to use such things
> as #[[1]] as variables.  Read the docs on "pure functions".

Hmm.  I had not heard of Sequence.  Learned something.

Joe Gwinn

[toc] | [prev] | [next] | [standalone]


#15324

FromDavid Bailey <dave@removedbailey.co.uk>
Date2013-08-17 06:01 +0000
Message-ID<kun3jg$3nj$1@smc.vnet.net>
In reply to#15309
On 16/08/2013 11:53, Samuel Mark Young 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
>
>
On 16/08/2013 11:53, Samuel Mark Young 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
 >
 >
Sequence@@ will remove a layer of parentheses inside another construct 
(such as Integrate). For example:

In[1]:= lim = {{x, 1, 10}};

In[2]:= Integrate[x^2, Sequence @@ lim]

Out[2]= 333

David Bailey
http://www.dbaileyconsultancy.co.uk

[toc] | [prev] | [standalone]


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


csiph-web