[Python-ideas] Support multiplication for sets

Mike Meyer mwm at mired.org
Fri Oct 7 23:51:53 CEST 2011


On Fri, Oct 7, 2011 at 2:29 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:

> On Fri, Oct 7, 2011 at 2:13 PM, Paul Moore <p.f.moore at gmail.com> wrote:
> > On 7 October 2011 18:15, Stephen J. Turnbull <turnbull at sk.tsukuba.ac.jp>
> wrote:
> >> Paul Moore writes:
> >>
> >>  > So your multiplication isn't commutative (the types of the elements
> in
> >>  > the 2 expressions above are different).
> >>
> >> No, set multiplication is not going to be commutative: {'a'} X {1} is
> >> quite different from {1} X {'a'}.  The problem you're pointing out is
> >> much worse: the obvious implementation of Cartesian product isn't even
> >> associative.
> >
> > Bah. For all my claims of having a mathematical background (OK, so it
> > was 30 years ago :-)) I can't even remember the difference between
> > associativity and commutativity.
>
> Associative: A * (B * C) == (A * B) * C
> Commutative: A * B == B * A
>

Associative is a problem. Especially because there are two reasonable
interpretations of it ( (a, (b, c)) vs. (a, b, c)).

Commutative, not so much. We already have a number of non-commutative
operators (-, /, // and % on most types), some of which behave that way in
the real world of mathematics. We also have operators that are commutative
on integers but not on other things (+ on lists and string).

   <mike
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20111007/ce8853ab/attachment.html>


More information about the Python-ideas mailing list