Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

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


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

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]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.