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: Re: [mg4180] How can this MapAt application be done more efficiently
Replies: 0  

Advanced Search

Back to Topic List Back to Topic List  
Andrei Constantinescu

Posts: 32
Registered: 12/7/04
Re: [mg4180] How can this MapAt application be done more efficiently
Posted: Jun 16, 1996 2:12 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

A possible solution is:

In[1]:= l = {{5, 0}, {4, 1}, {3, 2, 0}, {3, 1, 1}}

Out[1]= {{5, 0}, {4, 1}, {3, 2, 0}, {3, 1, 1}}

In[2]:= Position[l , 0 ]

Out[2]= {{1, 2}, {3, 3}}

In[11]:= Delete[ l , %2 ]

Out[11]= {{5}, {4, 1}, {3, 2}, {3, 1, 1}}


so you can combine all in your function:

dropzero[mylist_] := Delete[ mylist , Position[ mylist , 0 ]]

:-)


a + andrei

______________________________________________________________________
Andrei Constantinescu constant@athena.polytechnique.fr

LMS Ecole Polytechnique tel: (33)-1-69.33.33.30
91128 PALAISEAU cedex - FRANCE fax: (33)-1-69.33.30.26








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.