Re: Unwanted Recursion
- To: mathgroup at smc.vnet.net
- Subject: [mg120098] Re: Unwanted Recursion
- From: Kambis Veschgini <k.veschgini at thphys.uni-heidelberg.de>
- Date: Fri, 8 Jul 2011 04:53:23 -0400 (EDT)
- References: <iv1a95$sjl$1@smc.vnet.net> <iv45tf$f6i$1@smc.vnet.net>
On 2011-07-07 13:39:27 +0200, David Bailey said:
> On 06/07/2011 10:35, Casorati wrote:
>> I'm trying to define an anti-commutative algebra in Mathematica.
>> Here I will show only a minimal example to demonstrate my point.
>> The product of two elements a^b should be give by p[a,b] so I
>> make p flat:
>>
>> SetAttributes[p, {Flat}]
>>
>> But now I want p[a] to reduce to a.
>> Such a rule would make other rules much simpler but when I define
>>
>> p[a_] := a
>>
>> the expression p[a] causes an infinite recursion. I get the message
>>
>> $IterationLimit::itlim: Iteration limit of 4096 exceeded.
>>
>> I have similar problems with p[]:=1 which makes mathematica puts
>> ones into the p : p[a]=p[a,a]=p[1,1,...,a] .
>>
>> How can I solve this problem?
>>
>>
>
> I see no infinite recursion:
>
> In[649]:= p[a_]:=a;
>
> In[650]:= p[a]
>
> Out[650]= a
>
> I suggest you post a specific piece of code that reproduces this problem
> immediately after killing the kernel.
>
> I also wonder what the real purpose of p is.
>
> David Bailey
> http://www.dbaileyconsultancy.co.uk
I did but You left out the line SetAttributes(p,{Flat}) at the beginning.