Skip to content

Instantly share code, notes, and snippets.

@CodeDrome
Created August 13, 2022 12:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CodeDrome/3ed9982fb30d1e6325ac1ffbff92455d to your computer and use it in GitHub Desktop.
Save CodeDrome/3ed9982fb30d1e6325ac1ffbff92455d to your computer and use it in GitHub Desktop.
setutilities.py
from types import MappingProxyType
symbols = MappingProxyType({ "emptySet": "∅",
"union": "∪",
"intersection": "∩",
"is_element_of": "∈",
"is_not_element_of": "∉",
"is_subset_of": "⊆",
"is_proper_subset_of": "⊂",
"is_not_subset_of": "⊄",
"is_superset_of": "⊇",
"is_proper_superset_of": "⊃",
"is_not_superset_of": "⊅",
"natural_numbers": "ℕ",
"integers": "ℤ",
"rational_numbers": "ℚ",
"real_numbers": "ℝ",
"complex_numbers": "ℂ",
"power_set": "ℙ",
"universal_set": "ξ",
# this is minuscule Greek letter xi
# minuscule zeta ζ. V, U or S are also used.
"cartesian_product": "×",
"set_difference": "\\",
"symmetric_difference": "",
"cardinality": "|",
"complement": "'",})
def cardinality_string(set, setname):
result = f"{symbols['cardinality']}{setname}{symbols['cardinality']} = {len(set)}"
return result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment