Re: Color coding a Table entry

*To*: mathgroup at smc.vnet.net*Subject*: [mg92627] Re: Color coding a Table entry*From*: Albert Retey <awnl at gmx-topmail.de>*Date*: Thu, 9 Oct 2008 06:33:39 -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? >From other posts I believe you don't actually appreciate "functional" programming constructs to much. Anyway, this problem is a good demonstration how much simpler and clearer this can be than writing loops. Note that I tried to avoid arcane shortcuts like # and & for the formulation of the pure function: Map[ Function[{x}, If[x < 0, Style[x, Red], x]], Table[RandomReal[{-1, 1}, {3}], {x, 1, 3}], {2} ] Of course for presentation purposes you might want to wrap the result with a Grid or MatrixForm. hth, albert