Mathematica 9 is now available
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: [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


  • Prev by Date: Can Mathematica NIntegrate a Log-type singularity?
  • Next by Date: Re: Color coding a Table entry
  • Previous by thread: Re: Color coding a Table entry
  • Next by thread: Re: Color coding a Table entry