MathGroup Archive 2008

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

Search the Archive

Re: Replace non-numeric values in a list


On May 15, 9:50 pm, "Adel Elsabbagh" <aelsabb... at gmail.com> wrote:
> Dear all,
>
> 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?
> Thanks!
>
> --
> Adel Elsabbaghhttp://www.svlab-asu.com/aelsabbagh.html


list={a,1,2,b,3};
myfunc[x_] /; Not[NumberQ[x]] = 0;
myfunc[x_] = x;
newlist = Simplify[list,TransformationFunctions -> myfunc]


Output is
{0,1,2,0,3}


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