MathGroup Archive 2008

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

Search the Archive

Re: Color coding a Table entry

  • To: mathgroup at smc.vnet.net
  • Subject: [mg92638] Re: Color coding a Table entry
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Thu, 9 Oct 2008 06:35:45 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, UK
  • 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?

One possible way:

     f1 := RandomInteger[{-1, 1}];
     f2 := (-1)^x;
     f3 := Sin[N[x]];

     redneg[expr_] := If[expr < 0, Style[expr, Red], expr, expr]

     With[{xmin = 0, xmax = 10},
      Table[{f1, redneg[f2], f3}, {x, xmin, xmax}]]

Regards,
-- Jean-Marc


  • Prev by Date: Re: genetic algorithms
  • Next by Date: Re: genetic algorithms
  • Previous by thread: Re: Color coding a Table entry
  • Next by thread: Re: Color coding a Table entry