Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: Replace, test question
Replies: 6   Last Post: Jul 20, 2011 6:01 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
PA32R

Posts: 4
Registered: 7/18/11
Replace, test question
Posted: Jul 18, 2011 5:22 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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.




Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.