Details about pythons set implementation

Piet van Oostrum piet at cs.uu.nl
Fri Jan 4 21:02:23 CET 2008


>>>>> bukzor <workitharder at gmail.com> (B) wrote:

>B> Why cant you implement < for complex numbers? Maybe I'm being naive,
>B> but isn't this the normal definition?
>B>     a + bi < c + di iff sqrt(a**2 + b**2) < sqrt(c**2, d**2)

There doesn't exist a `normal' definition of < for the complex numbers. For
example you would expect that x<y and z<u would imply that x+z<y+u and
similar thing for other operators. This is impossible for complex numbers.
Now if you use it only for set building then you could relax the
constraints and use for example the lexicographical order.
-- 
Piet van Oostrum <piet at cs.uu.nl>
URL: http://pietvanoostrum.com [PGP 8DAE142BE17999C4]
Private email: piet at vanoostrum.org



More information about the Python-list mailing list