MathGroup Archive 1997

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

Search the Archive

Forcing 'Plus' to format nicely

  • To: mathgroup at smc.vnet.net
  • Subject: [mg8155] Forcing 'Plus' to format nicely
  • From: crose at c2.telstra-mm.net.au (Colin Rose)
  • Date: Sat, 16 Aug 1997 11:50:59 -0400
  • Organization: Theoretical Research Institute
  • Sender: owner-wri-mathgroup at wolfram.com

Greetings

I have a fn that gives output like this:

  In[]       ww = f[blah] 
  Out[]=

  { t[{6}],     2 t[{5,1}],   3 t[{4,2}], t[{4,1,1}], 2 t[{3,3}], 4 t[{3,2,1}],
    t[{2,2,2}],   t[{2,2,1,1}]}

Note how the t terms are nicely sorted: {6}, then {5, 1}, then {4, 2} etc
My desired output is actually Plus@@ww, but doing so ruins my nice ordering:

eg  In[]     Plus@@ww
    Out[]   

    t[{6}]+2 t[{3,3}]+3 t[{4,2}]+2 t[{5,1}]+t[{2,2,2}]+4 t[{3,2,1}]+t[{4,1,1}]+
    t[{2,2,1,1}] 


Any ideas how one can circumvent this problem inside a Module ?

One approach I thought of is as follows:

   In[]      Unprotect[Plus]; ClearAttributes[Plus, Orderless];  Plus@@ww

   Out[431]=
        t[{6}] + 2 t[{5,1}] + 3 t[{4,2}] + t[{4,1,1}] + 2 t[{3,3}] +
        4 t[{3,2,1}] + t[{2,2,2}] + t[{2,2,1,1}]

Unfortunately, in order to be a good citizen, I still have to
turn  SetAttributes[Plus, Orderless]; Protect[Plus]  back on in the same
Module[]. I don't see how one can do this AFTER generating the output
to screen (v3). Any ideas? It's driving me nuts.

Cheerio

Colin

-- 
Colin Rose 
tr(I) - Theoretical Research Institute
______________________________________
crose at c2.telstra-mm.net.au
http://www.usyd.edu.au/su/tri/


  • Prev by Date: Re: ListPlot with little plus signs instead?
  • Next by Date: Re: Expanding function names to explicit formulas
  • Previous by thread: Re: Strange result in MMa 3.0
  • Next by thread: Re: Forcing 'Plus' to format nicely