Re: Color coding a Table entry
- To: mathgroup at smc.vnet.net
- Subject: [mg92628] Re: Color coding a Table entry
- From: Albert Retey <awnl at gmx-topmail.de>
- Date: Thu, 9 Oct 2008 06:33:51 -0400 (EDT)
- References: <gci1tn$ji$1@smc.vnet.net>
AES wrote:
> I'm Printing (to the screen) a Table like, let's say,
>
> Table[{f1, f2, f3}, (x, xmin, xmax}]
>
> and anytime the value of f2 goes negative I want that value printed in
> Red.
>
> What's a simple, compact way to code this?
>
correcting my previous post: pattern matching is probably even better in
this case:
ReplaceAll[
Table[RandomReal[{-1, 1}, {3}], {x, 1, 3}],
x_?Negative :> Style[x, Red]
]