Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Re: First nonzero in list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg110847] Re: First nonzero in list
  • From: "David Park" <djmpark at comcast.net>
  • Date: Thu, 8 Jul 2010 06:50:45 -0400 (EDT)
  • References: <6775863.1278573914542.JavaMail.root@n11>

Position[th, Except[0], {1}] // Last

{25}


David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/  


From: S. B. Gray [mailto:stevebg at ROADRUNNER.COM] 

I have lists such as

th = {227, 342, 527, 0, 670, 730, 703, 0, 0, 649, 687, 614, 570, 501,
   462, 402, 325, 254, 189, 99, 81, 36, 9, 8, 3, 0, 0, 0, 0, 0, 0, 0,
   0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}

and I want to find the position of the last nonzero element (e.g. 3 at 
position 25). Trivial, but some poking around did not reveal a neat way.

Anyone? Thank you.

Steve Gray




  • Prev by Date: Re: First nonzero in list
  • Next by Date: Re: First nonzero in list
  • Previous by thread: Re: First nonzero in list
  • Next by thread: Re: First nonzero in list