Nostalgia for Algol68 ! The line OP OVER = (INT n,d)RAT: cancel(RAT(n,d));
is taken from my implementation of rational numbers so "one half" could be written 1 OVER 2 and I could also write DET M for the determinant of a matrix (ok, that's prefix not infix). Don't mock, my original tables of elliptic curves of conductor up to 1000 was computed with Algol68! John On 26/09/2007, Mike Hansen <[EMAIL PROTECTED]> wrote: > > No, I don't think you can make custom infix operators in Python. With > something as long as 'boxproduct', you'd probably just be better off > making it a method. > > --Mike > > On 9/26/07, Jason Grout <[EMAIL PROTECTED]> wrote: > > > > Mike Hansen wrote: > > > Since I don't think that graphs and polytopes fall under the SAGE > > > coercion model, overloading operators is pretty straightforward. You > > > just need to define the __add__ method in your class. x + y will call > > > x.__add__(y). > > > > > > sage: class Foo: > > > ....: def __add__(self, y): > > > ....: return 42 > > > ....: > > > sage: a = Foo() > > > sage: b = Foo() > > > sage: a + b > > > 42 > > > sage: b + a > > > 42 > > > > > > Note that you'll want to do some type-checking so that y is what you > > > actually think it should be. > > > > Can we define custom infix operators? Suppose I'd like "boxproduct" to > > be an infix operator. Could I make that work? > > > > Thanks, > > > > Jason > > > > > > > > > > > > > -- John Cremona --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-devel@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-devel URLs: http://sage.scipy.org/sage/ and http://modular.math.washington.edu/sage/ -~----------~----~----~----~------~----~------~--~---