Skip to content

Instantly share code, notes, and snippets.

@adntaha
Last active January 31, 2026 02:50
Show Gist options
  • Select an option

  • Save adntaha/0e39261e6f43d98cc8143b6646f7b84a to your computer and use it in GitHub Desktop.

Select an option

Save adntaha/0e39261e6f43d98cc8143b6646f7b84a to your computer and use it in GitHub Desktop.
had fun using recursive programming and set theory to mathematically define integers. unsurprisingly, the amount of brackets grows according to 2^n starting at 0.
>>> int_as_set = lambda n: [int_as_set(i) for i in range(n)]
>>> set_to_str = lambda s: "{" + ", ".join(set_to_str(e) for e in s) + "}"
>>> set_to_str(int_as_set(6))
'{{}, {{}}, {{}, {{}}}, {{}, {{}}, {{}, {{}}}}, {{}, {{}}, {{}, {{}}}, {{}, {{}}, {{}, {{}}}}}, {{}, {{}}, {{}, {{}}}, {{}, {{}}, {{}, {{}}}}, {{}, {{}}, {{}, {{}}}, {{}, {{}}, {{}, {{}}}}}}}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment