MathGroup Archive 2008

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

Search the Archive

Re: Don't understand behavior of ClearAttributes[Plus,Orderless]

  • To: mathgroup at smc.vnet.net
  • Subject: [mg84868] Re: Don't understand behavior of ClearAttributes[Plus,Orderless]
  • From: dh <dh at metrohm.ch>
  • Date: Wed, 16 Jan 2008 23:11:25 -0500 (EST)
  • References: <fmkfts$a4l$1@smc.vnet.net>

Hi Alain,

a precedence list can be found in the mathematica book: A.2.7.

For some info concerning order, see under "Sort".

hope this helps, Daniel



Alain Cochard wrote:

> I see from the archives that it is seldom a good idea to use

> ClearAttributes[Plus,Orderless] but I would nevertheless like to

> understand why it gives the behavior I expect in some cases and not in

> others, as exemplified below.

> 

>     Mathematica 6.0 for Linux x86 (32-bit)

>     Copyright 1988-2007 Wolfram Research, Inc.

> 

>     In[1]:= {b + a, j + 1, "/"+">"}

> 

>     Out[1]= {a + b, 1 + j, > + /}

> 

> To begin with, is it correct that the default ordering (as above) is

> defined by what is called "canonical order" in the documentation?  If

> so, I found only rudimentary (as it seemed to me anyway) descriptions

> of what canonical order is.  For example, it is said that

> 

>     "Mathematical operators appear in order of decreasing precedence."

> 

> But how am I supposed to know or to determine that "/" is "less

> preceding" than ">"?  Or maybe there are considered as strings here?

> Anyway, the question of why ">" comes before "/" remains.

> 

> Also, I did not find anything regarding ordering/comparison of

> elements from different classes of expressions, as I understand "1"

> and "j" are.

> 

> (Sorry if answers to these questions are easily found --I did search

> for them-- or if some questions don't even make sense.)

> 

>     In[2]:= ClearAttributes[Plus,Orderless]

> 

>     In[3]:= {b + a, j + 1, "/"+">"}

> 

>     Out[3]= {b + a, 1 + j, / + >}

> 

> Here I get the behavior I expect for b + a and "/"+">" (order

> unchanged in output) but not for j + 1, changed to 1 + j.  Why?

> 

> Thanks for any hint.

> Alain 

> 

> 




  • Prev by Date: Simplifying integer expressions with Mod and BitAnd
  • Next by Date: Re: Version 6 graphics can be painfully slow
  • Previous by thread: Re: Don't understand behavior of ClearAttributes[Plus,
  • Next by thread: Can you minimize a notebook window from a notebook in Version 6? and