|
|
Log in / Subscribe / Register

Toward a conclusion for Python dictionary "addition"

Toward a conclusion for Python dictionary "addition"

Posted Mar 22, 2024 8:06 UTC (Fri) by SomeOtherGuy (guest, #151918)
In reply to: Toward a conclusion for Python dictionary "addition" by 0thgen
Parent article: Toward a conclusion for Python dictionary "addition"

| is more formally correct, the definition of union is an axiom of set theory (another axiom shows its unique) but basically:

The union of A and B contains an element x if and only if (x is in A _OR_ x is in B)

Intersection is "and"

Some authors (notably Russian) - eg Krzysztof Maurin use a big "V" like symbol for union (which is a symbol for or) and a ^ like symbol for intersection (^ (upside down vee) being a symbol for and)

BUT this doesn't really matter! Python isn't APL :P

Also a map/dict represents a function, set theory wise a function from sets A to B is a relation (subset of A times B - the cartesian product) such that there exists exactly one b in B such that f(a)=b for some (possibly multiple) a in A.

This means that if we write f(a)=b and f(a)=c then b=c a function is a kind of relation.

Functions are not closed under set union, that is the union of two functions need not be a function (indeed it's usually not)

Isn't maths fun :)


to post comments


Copyright © 2026, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds