MathGroup Archive 2007

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

Search the Archive

Re: Scalars Instead of Lists with One Element


Your example below confuses your question, because if x={2,7} then x 
[[1]==2 && x[[2]]==7. I recall an earlier post of yours, however, in  
which you wanted lists of one element to be replaced by that element.  
The following simple rule does this

r1={e_}:>e

For example,

In[265]:= {{3,4},{2},{1,2},{3}}/.r1
Out[265]= {{3,4},2,{1,2},3}

This simple rule and application can be tweaked to avoid failures in  
special cases. Read the docs.

> Say I have the list x={2, 7}.  Is there a command I can use to get  
> 2  rather than {2} when I ask for x[[1]], and 7 rather than {7}  
> when I  ask for x[[2]]?  Doing so would solve my problem with my  
> tables being  too deep to be able to cut and paste directly into  
> the table objects  of other applications like word processors and  
> spread sheets.


  • Prev by Date: ListAnimate and GIF format saving
  • Next by Date: Re: Using FindRoot
  • Previous by thread: Re: Scalars Instead of Lists with One Element
  • Next by thread: Re: Scalars Instead of Lists with One Element