|
[Date Index]
[Thread Index]
[Author Index]
Simulating the behaviour of Plus and Times.
- To: mathgroup at smc.vnet.net
- Subject: [mg75858] Simulating the behaviour of Plus and Times.
- From: Szabolcs <szhorvat at gmail.com>
- Date: Sat, 12 May 2007 03:03:17 -0400 (EDT)
- Organization: University of Bergen
Is it possible to define two functions whose behaviour is the same as
that of Plus, Times and Minus in circumstances similar to the ones
illustrated below?
In[1]:= 1+2
Out[1]= 3
In[2]:= a + a
Out[2]= 2 a
In[3]:= 3a + 5a
Out[3]= 8 a
In[4]:= x a + y a
Out[4]= a x + a y
In[5]:= 3(a+b) + 2(a+b)
Out[5]= 5 (a+b)
In[6]:= 0a
Out[6]= 0
In[7]:= a-a
Out[7]= 0
Could someone show me how to define two such functions, plus and times,
that operate on integers represented as num[someNumber]? Example:
In := plus[times[num[2], plus[a, b]], times[plus[a, b], num[3]]]
Out = times[num[5], plus[a, b]]
In := plus[times[num[-1], a], a]
Out = num[0]
Prev by Date:
Coordinate conversion with Grad
Next by Date:
Shadows in Mathematica 6
Previous by thread:
Re: Coordinate conversion with Grad
Next by thread:
Shadows in Mathematica 6
|