MathGroup Archive 2002

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

Search the Archive

RE: RE: Re: Seemingly simple gridbox question

  • To: mathgroup at smc.vnet.net
  • Subject: [mg37645] RE: [mg37562] RE: [mg37536] Re: Seemingly simple gridbox question
  • From: "DrBob" <drbob at bigfoot.com>
  • Date: Thu, 7 Nov 2002 06:42:02 -0500 (EST)
  • Reply-to: <drbob at bigfoot.com>
  • Sender: owner-wri-mathgroup at wolfram.com

Two questions:

First, the following code does exactly the same thing, so what was
Unevaluated[Sequence[]] intended to do?

DisplayForm[
  GridBox[MapIndexed[
      StyleBox[ToString[#1], 
          If[s[#2, blockHigh], FontColor -> Hue[0]]] &, m, {2}]]]
MatrixForm[
  MapIndexed[
    DisplayForm[
        StyleBox[ToString[#1], 
          If[s[#2, blockHigh], ,
            FontColor -> GrayLevel[.5]], FontWeight -> "Bold"]] &, m,
{2}]]

Second, if I page up after evaluating the code, so that the output is
hidden, and then page down again so that I can see it again, the gray
cells have changed color.  Does anyone else see that, or am I losing my
mind?  (Mathematica 4.2, WinXP.)

DrBob

-----Original Message-----
From: Wolf, Hartmut [mailto:Hartmut.Wolf at t-systems.com] 
To: mathgroup at smc.vnet.net
Subject: [mg37645] [mg37562] RE: [mg37536] Re: Seemingly simple gridbox question


>-----Original Message-----
>From: Mike [mailto:mikeh1980 at optusnet.com.au]
To: mathgroup at smc.vnet.net
>Sent: Monday, November 04, 2002 8:44 AM
>To: mathgroup at smc.vnet.net
>Subject: [mg37645] [mg37562] [mg37536] Re: Seemingly simple gridbox question
>
>
>On 3/11/02 9:25 AM, "Mike" <mikeh1980 at optusnet.com.au> wrote:
>
>> I have a 3x3 gridbox and I would like to enclose a 2x2 block 
>within in
>> parenthesis to indicate to a reader that I am operating only 
>on that part of
>> the matrix (gridbox).
>> 
>> I can only seem to get parethesis added to individual 
>elements. Any ideas?
>> 
>> Thanks
>> 
>> Mike
>
>Actually it was simple:
>
>
>Cell[TextData[Cell[BoxData[
>    RowBox[{"(", GridBox[{
>          {
>            RowBox[{"(", GridBox[{
>                  {"0", "0"},
>                  {"0", "0"}
>                  }], ")"}], GridBox[{
>                {"0"},
>                {"0"}
>                }]},
>          {GridBox[{
>                {"0", "0"}
>                }], "0"}
>          }], ")"}]]]], "Text"]
>
>Mike
>
>

As you found out by yourself, it rests to note, that there are perhaps
more
attractive ways to highlight a block of a matrix:

In[85]:= m = Partition[Range[9], 3]
Out[85]= {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}

In[86]:=
s[p_, {{l1_, l2_}, {u1_, u2_}}] := And @@ Thread[{l2, l1} <= p <= {u2,
u1}]

In[87]:= blockHigh = {{2, 2}, {3, 3}};

In[88]:=
DisplayForm[
  GridBox[MapIndexed[
      StyleBox[ToString[#1], 
          If[s[#2, blockHigh], FontColor -> Hue[0], 
            Unevaluated[Sequence[]]]] &, m, {2}]]]

...or if you like

In[89]:= blockHigh = {{2, 1}, {3, 2}};
In[90]:=
MatrixForm[
  MapIndexed[
    DisplayForm[
        StyleBox[ToString[#1], 
          If[s[#2, blockHigh], Unevaluated[Sequence[]], 
            FontColor -> GrayLevel[.5]], FontWeight -> "Bold"]] &, m,
{2}]]

--
Hartmut Wolf






  • Prev by Date: RE: RE: Re: Seemingly simple gridbox question
  • Next by Date: Re: Re: indeterminate expression
  • Previous by thread: RE: RE: Re: Seemingly simple gridbox question
  • Next by thread: RE: RE: RE: Re: Seemingly simple gridbox question