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


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

Selecting round parentheses arguments

Started byJJ <wateronwildfire@gmail.com>
First post2011-04-09 11:13 +0000
Last post2011-04-09 22:01 +0000
Articles 2 — 2 participants

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


Contents

  Selecting round parentheses arguments JJ <wateronwildfire@gmail.com> - 2011-04-09 11:13 +0000
    Re: Selecting round parentheses arguments David Bailey <dave@removedbailey.co.uk> - 2011-04-09 22:01 +0000

#1558 — Selecting round parentheses arguments

FromJJ <wateronwildfire@gmail.com>
Date2011-04-09 11:13 +0000
SubjectSelecting round parentheses arguments
Message-ID<inpf0a$906$1@smc.vnet.net>
Hello again everybody,
Chelly question made me think to something. Suppose I have a list like this:

p={a b (c 3 d)+a c (b^2 5),b (c+d 4)-a,-(a^3 d) c}

in which the round parentheses (except for the middle one) are unnecessary
but play a semantic role by dividing some expressions from others with
different meaning. Now let's say I want to extract the expressions inside
those parentheses and obtain

ans={{c 3 d,b^2 5},c+d 4, a^3 d}

Is there a quick way to do that?

thanks

[toc] | [next] | [standalone]


#1583

FromDavid Bailey <dave@removedbailey.co.uk>
Date2011-04-09 22:01 +0000
Message-ID<inql04$e9l$1@smc.vnet.net>
In reply to#1558
On 09/04/2011 12:13, JJ wrote:
> Hello again everybody,
> Chelly question made me think to something. Suppose I have a list like this:
>
> p={a b (c 3 d)+a c (b^2 5),b (c+d 4)-a,-(a^3 d) c}
>
> in which the round parentheses (except for the middle one) are unnecessary
> but play a semantic role by dividing some expressions from others with
> different meaning. Now let's say I want to extract the expressions inside
> those parentheses and obtain
>
> ans={{c 3 d,b^2 5},c+d 4, a^3 d}
>
> Is there a quick way to do that?
>
> thanks

First, if you want to do this by hand, it is possible to click inside an 
expression, and then spread the selection to cover successively larger 
sub-expressions using Ctrl-. This would allow you to select, and then 
copy particular parenthesised expressions.

Alternatively, you could write code to read a cell in BoxForm, and seek 
out sub expressions of the BoxForm of the form RowBox[{"("........ I 
don't know that this would really be worth the effort.

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

[toc] | [prev] | [standalone]


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


csiph-web