MathGroup Archive 2008

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

Search the Archive

Re: how to get rid of extra parentheses ?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg92526] Re: how to get rid of extra parentheses ?
  • From: Peter Pein <petsie at dordos.net>
  • Date: Thu, 2 Oct 2008 18:48:43 -0400 (EDT)
  • References: <gc2167$qa4$1@smc.vnet.net>

Say you've got this result:
In[1]:= result = {{cb*S*(V/2)}};

Take the first element of the first sublist:
In[2]:= desiredResult = result[[1,1]]
Out[2]=
(cb*S*V)/2

If you get deeper nested results like:
In[3]:= r5 = Nest[List, cb*S*(V/2), 5]
Out[3]=
{{{{{(cb*S*V)/2}}}}}

then you can flatten this structure to a simple list and take the first part
In[4]:= First[Flatten[r5]]
Out[4]=
(cb*S*V)/2

which gives the same result as this  step-by-step-method:
In[5]:= NestWhile[First, r5, ListQ]
Out[5]= (cb*S*V)/2

hth,
Peter

Obaid Rehman schrieb:
> Hi , there
> 
> 
> 
> I am wondering if some one can help me in my issue.
> 
> 
> 
> After some Algebraic manipulation I get the result but it is inside the
> two parenthesis e.g. {{...........  }}. The problem is that Mathematica
> understand it as a list or matrix entry.
> 
> If I need to use this result directly into the matrix manipulation it
> gives the error. Question is how to get rid these extra parentheses in
> the result that Mathematica add itself?
> 
> 
> 
> e.g
> 
> 
> 
> {{cb S V/ 2}}
> 
> 
> 
> U can see there is no need of these extra parenthesis
> 
> Obaid
> 
> 


  • Prev by Date: Re: Print A Math Formula In Formatted Notebook
  • Next by Date: Re: how to get rid of extra parentheses ?
  • Previous by thread: Re: how to get rid of extra parentheses ?
  • Next by thread: Re: how to get rid of extra parentheses ?