Services & Resources / Wolfram Forums / MathGroup Archive
-----

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: [mg88786] Re: [mg88745] Replace non-numeric values in a list
  • From: DrMajorBob <drmajorbob at att.net>
  • Date: Fri, 16 May 2008 05:34:23 -0400 (EDT)
  • References: <12929374.1210891275393.JavaMail.root@m08>
  • Reply-to: drmajorbob at longhorns.com

list = {a, 1, 2, b, 3};
Replace[list, {x_?NumericQ -> x, x_ -> 0}, 1]

{0, 1, 2, 0, 3}

or

Replace[list, x_ /; ! NumericQ[x] -> 0, 1]

{0, 1, 2, 0, 3}

Bobby

On Thu, 15 May 2008 06:50:03 -0500, Adel Elsabbagh <aelsabbagh 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!
>



-- 

DrMajorBob at longhorns.com


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