MathGroup Archive 2011

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

Search the Archive

Replace, test question


I'm very new to Mathematica and trying to work my way through it. I
don't understand why:
{58, 61, 15, 66, 10, 2, 24, 81, 45, 84} /. x_ /; PrimeQ -> P
returns:
{58, 61, 15, 66, 10, 2, 24, 81, 45, 84}

I would expect it to take the list, replace everything in the list
that matches any pattern and passes the PrimeQ test, i.e., is prime,
with P to yield:
{58, P, 15, 66, 10, P, 14, 81, 45, 84}

Can someone explain my misunderstanding?

Thanks.


  • Prev by Date: Re: Numerical accuracy/precision - this is a bug or a feature?
  • Next by Date: Re: Solve never calls Equal?
  • Previous by thread: Re: numeric Groebner bases et al [Was Re: Numerical accuracy/precision - this is a bug or a feature?]
  • Next by thread: Re: Replace, test question