Services & Resources / Wolfram Forums / MathGroup Archive
-----

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: [mg92623] Re: [mg92617] Color coding a Table entry
  • From: Meng Lu <lumeng at gmail.com>
  • Date: Thu, 9 Oct 2008 06:32:56 -0400 (EDT)
  • References: <200810081026.GAA00595@smc.vnet.net>
  • Reply-to: lumeng at gmail.com

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 way is

Print[Table[{Sin[x], If[# < 0, Style[#, Red], #] &@Cos[x], x}, {x, 1,
   10}]]

{{Sin[1],Cos[1],1},{Sin[2],Cos[2],2},{Sin[3],Cos[3],3},{Sin[4],Cos[4],\
4},{Sin[5],Cos[5],5},{Sin[6],Cos[6],6},{Sin[7],Cos[7],7},{Sin[8],Cos[\
8],8},{Sin[9],Cos[9],9},{Sin[10],Cos[10],10}}



  • Prev by Date: Re: Color coding a Table entry
  • Next by Date: Re: Call Mathematica functions using C program
  • Previous by thread: Color coding a Table entry
  • Next by thread: Re: Color coding a Table entry