Re: data structure / object
- To: mathgroup at smc.vnet.net
- Subject: [mg16383] Re: data structure / object
- From: "Allan Hayes" <hay at haystack.demon.co.uk>
- Date: Thu, 11 Mar 1999 02:16:51 -0500
- References: <7bt50n$nbn@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
schatzi wrote in message <7bt50n$nbn at smc.vnet.net>... >Hello, > >I would to do the following with Mathematica 3.0 : > >Define a data structure, fot example point[x,y], and then overload >operators, >and in particular the output operator. > >That is to say to be able to write >p=point[1,2];q=point[-1,3];r=p+q >pt[0,5] > >Thank you very much for your solutions, (and pointers to books/references). > > >antoine.zahnd at iprolink.ch > Tag the definition with point point/:point[p_,q_]+point[r_,s_]:= point[p+r,q+s]; Then point[1,2]+point[2,3]+point[3,4] Allan --------------------- Allan Hayes Mathematica Training and Consulting Leicester UK www.haystack.demon.co.uk hay at haystack.demon.co.uk Voice: +44 (0)116 271 4198 Fax: +44 (0)870 164 0565 point[6,9]