Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1993
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1993

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

Search the Archive

Lists

  • To: mathgroup at yoda.physics.unc.edu
  • Subject: Lists
  • From: neilb at physics.su.oz.au (RiemannZeta(s))
  • Date: Thu, 28 Jan 93 16:51:11 EST

Hi, I am try to add one to the last element of a list.
For example

>In[1]:= l={x,y,z}
>
>Out[1]= {x, y, z}
>
>In[2]:=  l/.l[[Length[l] ]]->l[[Length[l] ]]+1
>
>Out[2]= {x, y, 1 + z}

which works fine,
similarly

>In[3]:= l={x,y,z,0}
>
>Out[3]= {x, y, z, 0}
>
>In[4]:=  l/.l[[Length[l] ]]->l[[Length[l] ]]+1
>
>Out[4]= {x, y, z, 1}

but

>In[5]:= l={x,z,y,0,0}
>
>Out[5]= {x, z, y, 0, 0}
>
>In[6]:=  l/.l[[Length[l] ]]->l[[Length[l] ]]+1
>
>Out[6]= {x, z, y, 1, 1}
>
which is curious. Does anybody know why
this doesn't produce
{x,y,z,0,1}?

Many thanks
Neil






  • Prev by Date: General Protection Fault in WIndows
  • Next by Date: Symposium on QE & CAD
  • Previous by thread: General Protection Fault in WIndows
  • Next by thread: Re: Lists