Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #3548

Re: Unwanted Recursion

From Bill Rowe <readnews@sbcglobal.net>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Unwanted Recursion
Date 2011-07-07 11:42 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <iv4637$f8u$1@smc.vnet.net> (permalink)

Show all headers | View raw


On 7/6/11 at 5:39 AM, casorati@f-m.fm (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:

Unless you are inventing new syntax a^b is not the product of a
and b. It is a raised to the b power.

>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.

While I cannot explain precisely why this message occurs I can
confirm I get the same result when I set the attributes for p to
be Flat. However, if I do not set the attributes of p then
things work fine as demonstrated by:

In[1]:= p[a_] := a

In[2]:= p[a]

Out[2]= a

and given that p has been defined with a single argument, it
makes no sense for it to also have the attribute Flat.

If you were to define p to take an arbitrary number of arguments
and give it the attribute Flat, i.e.,

In[6]:= Clear[p]

In[7]:= SetAttributes[p, {Flat}]

In[8]:= p[a__] := a

In[9]:= p[a, b]

Out[9]= Sequence[a,b]

the error message doesn't occur.

Back to comp.soft-sys.math.mathematica | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

Re: Unwanted Recursion Bill Rowe <readnews@sbcglobal.net> - 2011-07-07 11:42 +0000
  Re: Unwanted Recursion Kambis Veschgini <k.veschgini@thphys.uni-heidelberg.de> - 2011-07-08 09:00 +0000

csiph-web