Boolean tests [was Re: Attack a sacred Python Cow]

Erik Max Francis max at alcyone.com
Mon Aug 4 05:25:43 EDT 2008


Antoon Pardon wrote:

> Maybe I'm going to be pedantic here, but I fear that your code won't
> work with matrices. The problem is that multiplication is not
> commutative with matrices. This means that matrices have two divisions a right
> and a left division. A far as I know the "/" operator usaly implements
> the left division while solving is done by using a right division.
> 
> So your code will probably fail when applied to matrices.

You're right in your general point, but usually division between 
matrices isn't defined at all because of this ambiguity.  However the 
general point can still exist between `solveLeft` and `solveRight` 
functions which do something along the lines of a*b**-1 and a**-1*b.  A 
single `solve`, of course, would choose one of these, and syntactically 
it might be quite reasonable to define matrix division that does one of 
these and have a single `solve` function that accomplishes it.

Therefore, the general point about polymorphism still stands.

-- 
Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
  San Jose, CA, USA && 37 18 N 121 57 W && AIM, Y!M erikmaxfrancis
   It is human nature to think wisely and act foolishly.
    -- Anatole France



More information about the Python-list mailing list