MathGroup Archive 1995

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

Search the Archive

Function with attributes Flat and OneIdentity

  • To: mathgroup at christensen.cybernetics.net
  • Subject: [mg1078] Function with attributes Flat and OneIdentity
  • From: Marc Mazzariol <mmazzari at didec14.epfl.ch>
  • Date: Fri, 12 May 1995 18:21:05 -0400
  • Organization: Ecole Polytechnique Federale de Lausanne

Hello, I'm a student and i'm trying to use mathematica.

I've a little problem :

I want to define a function r that has the attributes Flat and OneIdentity so i
write :
		Attributes[r] = {Flat,OneIdentity};

Now if i ask mathematica for :
		r[r[a]]
the result is :
		r[a]
But i want to have the result : a   (and not r[a])

If i ask mathematica for :
		r[a]
the result is :
		r[a]
But i also want : a    (and not r[a])

So i've tried to write :
		r[x_] := x

Now if i ask mathematica for :
		r[a]  
or for :
		r[r[a]]
i've the right result : a

But now there is another problem :


if i ask mathematica for :
   		r[a,a]
mathematica says :
 	
		$IterationLimit::itlim: Iteration limit of 4096 exceeded.
And this because of the attributes of r.

So my problem is that i want to create a function like Plus :

	Plus has the attributes Flat and OneIdentity
	Plus[2] gives 2	(and not Plus[2] like my function r does)
	Plus[Plus[2]] gives 2 ( ""              ""         ""  )
	Plus[2,2] gives 4  (and not $Itera... like my function r does)

How can I do it ????

Thanks for help



  • Prev by Date: Re: Ouestion about Ploting?
  • Next by Date: Re: In[1]:= Question
  • Previous by thread: Mma Sound
  • Next by thread: Re: Function with attributes Flat and OneIdentity