Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #3786

Replace, test question

From PA32R <tio540s1@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Replace, test question
Date 2011-07-18 10:15 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <j0113e$qad$1@smc.vnet.net> (permalink)

Show all headers | View raw


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.

Back to comp.soft-sys.math.mathematica | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Replace, test question PA32R <tio540s1@gmail.com> - 2011-07-18 10:15 +0000
  Re: Replace, test question Peter Breitfeld <phbrf@t-online.de> - 2011-07-19 11:06 +0000
  Re: Replace, test question "Oleksandr Rasputinov" <oleksandr_rasputinov@hmamail.com> - 2011-07-19 11:11 +0000
  Re: Replace, test question Yves Klett <yves.klett@googlemail.com> - 2011-07-19 11:12 +0000
    Re: Replace, test question PA32R <tio540s1@gmail.com> - 2011-07-20 10:39 +0000

csiph-web