|
|
Log in / Subscribe / Register

Toward a conclusion for Python dictionary "addition"

Toward a conclusion for Python dictionary "addition"

Posted May 29, 2020 0:56 UTC (Fri) by 0thgen (guest, #139205)
Parent article: Toward a conclusion for Python dictionary "addition"

im a big fan of using the addition symbol

it seems like the correct symbol for the union of two sets is `∪` anyways, so it's not like using `|` is more formally correct anyways
(source: https://en.wikipedia.org/wiki/Union_(set_theory))


to post comments

Toward a conclusion for Python dictionary "addition"

Posted Mar 22, 2024 8:06 UTC (Fri) by SomeOtherGuy (guest, #151918) [Link]

| 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 :)


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