MathGroup Archive 2008

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

Search the Archive

Re: Replace non-numeric values in a list


On 5/15/08 at 7:50 AM, aelsabbagh at gmail.com (Adel Elsabbagh) wrote:

>I have a list that contains numeric and non-numeric values list = {
>a, 1, 2, b, 3}; How can I replace non-numeric values with zeros?

Here is one way to do what you want

In[12]:= list /. Thread[DeleteCases[list, _?NumericQ] -> 0]

Out[12]= {0,1,2,0}


  • Prev by Date: Re: Replace non-numeric values in a list
  • Next by Date: Re: Replace non-numeric values in a list
  • Previous by thread: Re: Replace non-numeric values in a list
  • Next by thread: Re: Replace non-numeric values in a list