       Re: Graphics manipulation question

• To: mathgroup at smc.vnet.net
• Subject: [mg8371] Re: Graphics manipulation question
• From: tburton at cts.com (Tom Burton)
• Date: Tue, 26 Aug 1997 20:41:06 -0400
• Organization: Brahea Consulting
• Sender: owner-wri-mathgroup at wolfram.com

```On 22 Aug 1997 04:41:06 -0400, in comp.soft-sys.math.mathematica you =
wrote:

>Suppose one has a Mathematica Graphics expression called g. And suppose
>further that one has a list of graphics primitives called p. And one has
>a boolean test function t. I want to transform the graphics expression g
>in the following way. Each time I encounter a primitive q in g that
>satisfies the boolean test function t I want to replace that primitive q
>with {q,First[p]} and to then delete the first element of p. If the
>primitive q does not satisfy t, then I want to leave q alone. A
>practical application of this concept might be to ascribe different
>colors to some points scattered through a graphics expression.
>
>Any ideas how to do this with a modicum of elegance?
>
>Seth J. Chandler
>Associate Professor of Law
>University of Houston Law Center
>

I don't claim elegant, but the following is simple enough:

In:=3D p =3D {"a", "b", "c", "d", "e"};=20
In:=3D g =3D {1, 2, 3, 4, 5}; n =3D 1;=20
In:=3D g /. (j_Integer)?EvenQ :>{j, p[[n++]]}
Out=3D {1, {2, "c"}, 3, {4, "d"}, 5}
Tom Burton

```

• Prev by Date: Re: FullSimplify[Sum[1/(n^2 +n+1)^2,{n,1,p}]]?
• Next by Date: Stream Line Plots
• Previous by thread: Re: Graphics manipulation question
• Next by thread: Plotting Solids in Mathematica