5 ms·
If a+b != b+a that breaks the commutativity property of addition.
by vivekseth 8y ago
If a+b != b+a that breaks the commutativity property of addition.
- jcheng 8y ago"a"+"b" != "b"+"a" already.
- davidwtbuxton 8y agoYes, but I still want this for combining dictionaries. Python already violates this property, I don't find it confusing. Python 3.7.2 (default, Dec 30 2018, 08:55:50) [Clang 10.0.0 (clang-1000.11.45.5)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> 'foo' + 'bar' == 'bar' + 'foo' False >>> ['foo'] + ['bar'] == ['bar'] + ['foo'] False
- frabert 8y agoCommutatitivity does not need to always hold. Multiplication is not commutative on matrices, but we still use it often and write it as a product nonetheless
- whatshisface 8y agoPython actually supports a special operator @ for non-commutative matrix products.
- Koshkin 8y agoIn mathematics, the ‘multiplication’ operation is not assumed to be commutative, whereas the ‘addition’ operator is used specifically to indicate commutativity. So, for example, using the plus sign for string concatenation goes against this tradition.
- phkahler 8y agoThat property is not universal, and it is currently being defined for Python dictionaries. You can't break a property that isn't defined yet. ;-)
- selimthegrim 8y agoIs this what changed in 3.5?
- dnautics 8y agoTo be fair, IEEE fp addition is noncommutative in corner cases.