Re: Re: Problem with Mathematica 6

```On 3 Jun 2007, at 19:09, Carl Woll wrote:

> The problem is that NonCommutativeMultiply is Flat and OneIdentity,
> so I
> think
>
> NonCommutativeMultiply[a,b]
>
> is being interpreted as
> NonCommutativeMultiply[NonCommutativeMultiply[a],b] which gets
> converted
> to NonCommutativeMultiply[Times[a],b] and then
> NonCommutativeMultiply[a,b] and so you get an iteration error. To
> avoid
> this Flat issue, use HoldPattern:
>
> Unprotect[NonCommutativeMultiply];
> 1) := Times[a];
> Protect[NonCommutativeMultiply];
>
> Now, it works:
>
> In[347]:= a ** b
> Out[347]= a**b
>
> Carl Woll
> Wolfram Research
>

I don't think it is quite as simple as that.

In[1]:= ClearAttributes[NonCommutativeMultiply, OneIdentity]
In[2]:= Attributes[NonCommutativeMultiply]
Out[2]= {Flat, Protected}
Fermion[a__] := ((Grading[#1] = 1) &) /@ {a};
Fermion[a, b];
In[7]:= Unprotect[NonCommutativeMultiply];
NonCommutativeMultiply[a___] /; (Length[GetGradeds[a]] <= 1) := Times
[a];
Protect[NonCommutativeMultiply];
In[10]:= a ** b

and you get exactly the same problem. Also, see my post in this
thread that shows that clearly there has been a change in the way
pattern works. Namely, running

a ** b /. NonCommutativeMultiply[x___] /; (Print[{x}];
Length[{x}] <= 1) :> f[x]

gives different output in Mathematica 5.2 and 6.0. To me it seems
clear that the behaviour in 6 is an imporovement, but the OneIdentity
attribute alone does not seem to be responsible for it.

Andrzej Kozlowski

```

• Prev by Date: RE: simple question
• Next by Date: Re: MakeExpression problem
• Previous by thread: Re: Problem with Mathematica 6
• Next by thread: Re: Problem with Mathematica 6