Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1996
*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 1996

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

Search the Archive

Re: How can this MapAt application be done more efficiently

  • To: mathgroup at smc.vnet.net
  • Subject: [mg4222] Re: [mg4180] How can this MapAt application be done more efficiently
  • From: jpk at apex.mpe.FTA-Berlin.de (Jens-Peer Kuska)
  • Date: Tue, 18 Jun 1996 03:27:02 -0400
  • Sender: owner-wri-mathgroup at wolfram.com

> I have written a function to Drop any zero's from a table of numbers.
> Here is an example:
> 
> 	In[161]:= dropzero[ {{5, 0}, {4, 1}, {3, 2, 0}, {3, 1, 1}} ]
> 
> 	Out[161]= {{5}, {4, 1}, {3, 2}, {3, 1, 1}}

Hi Joel,

With
In[]:=
lst={{1,2,0,5,0},{4,6},{0,0,3,4,6,0}};

Try

In[]:=

lst //. {a___,0,b___} :> {a,b}

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


to remove all zeros and
try

lst //. {a___,0} :> {a}

to remove only zeros at the end of every list.

Hope that helps 

Jens




==== [MESSAGE SEPARATOR] ====


  • Prev by Date: Re: Re: (Q) Mathematica and Microsoft Equation Editor ?
  • Next by Date: Re: How to Solve a Quadratic Programming problem?
  • Previous by thread: Re: How can this MapAt application be done more efficiently
  • Next by thread: Re: How can this MapAt application be done more efficiently