MathGroup Archive 2008

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

Search the Archive

Re: Replace non-numeric values in a list

  • To: mathgroup at smc.vnet.net
  • Subject: [mg88803] Re: Replace non-numeric values in a list
  • From: Szabolcs <szhorvat at gmail.com>
  • Date: Fri, 16 May 2008 06:26:39 -0400 (EDT)
  • References: <g0h825$mtr$1@smc.vnet.net> <g0jkbm$11s$1@smc.vnet.net>

On May 16, 11:32 am, Steven Siew <stevensi... at gmail.com> wrote:
> 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
>
> Surprisingly the script below fails. Anyone want to comment?
>
> list = { a, 1, 2, b, 3};
>
> newlist2 = list /. v_?(Not[NumericQ[#]] &) -> 0

This is because the pattern you used matches the whole list (which is
not a numeric quantity).


  • Prev by Date: Re: Re: HoldForm, TraditionalForm Bug?
  • Next by Date: Re: Applying the Integration Function to a List Of Regions
  • Previous by thread: Re: Replace non-numeric values in a list
  • Next by thread: Re: Re: Replace non-numeric values in a list