The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Inactive » comp.soft-sys.math.mathematica

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: [mg6135] Re: [mg6120] selecting from lists
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
Lou Talman

Posts: 876
Registered: 12/3/04
[mg6135] Re: [mg6120] selecting from lists
Posted: Feb 23, 1997 12:18 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

Murray Eisenberg wrote:

> ...construct a
> function firstnonzero that returns the index of the first nonzero
> entry in a list (or, more generally, the first entry in a list
> satisfying a given property).

firstNonZero[s_] := First[Flatten[Position[s, x_ /; x != 0]]]

To extend this to conditions other than "non-zero" relplace the test
"x != 0" with the desired condition.

--Lou Talman

Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.