Skip to main content

Implementation of a Boolean toggle function according to the KISS ("Keep it sophisticated, specialist!") principle

Project description

cursed-toggle

This library is intended to implement a toggle function for Boolean values in a very bad or even the worst and most unmaintainable way, following the KISS ("Keep it sophisticated, specialist!") principle.

Preamble

The variable b can be True (1) or False (0). One of the most basic implementation to get a toggle is

f(b) = not b

But this is way too simple and efficient and something cooler looking might be

f(b) = b^1

A trivial linear function is also possible

f(b) = 1 - b

and this sounds like a good start.

The complication

Midamble

Not even sure whether this is a word. Anyway, after each modification, there should be a $\LaTeX$-like representation of the "math" and after, the correspdoning python syntax (needed for testing this readme).

The complication, take 2. Or take 1?. We should satisfy both index people. Take 2, Take 1, Take 0, Go!

The start function looks too negative and too simple. Let's make it positve and more complex, because $i^2 = -1$

$$ f(b) = 1 + i^2 \cdot b $$

f(b) = 1 + 1j**2 * b

The single lonely 1 in the beginning is also a bit boring. And since $e^{i\pi} + 1 = 0$, we know what to do.

$$ f(b) = -e^{i\pi} + i^2 \cdot b $$

f(b) = -(math.e**(1j * math.pi)).real + 1j**2 * b

Square 2. Two. 2 is 2 lame. Shifting 1234567 19 times to the right is also two. So, we will rightshift it 13 and 6 times.

$$ f(b) = -e^{i\pi} + i^{1234567 >> 13 >> 6} \cdot b $$

f(b) = -(math.e**(1j * math.pi)).real + 1j**(1234567 >> 13 >> 6) * b

$3! = 6$, so let's get rid of the 6.

$$ f(b) = -e^{i\pi} + i^{1234567 >> 13 >> 3!} \cdot b $$

f(b) = -(math.e**(1j * math.pi)).real + 1j**(1234567 >> 13 >> math.factorial(3)) * b

During my research, I stumbled across the DRY-principle, that means "Do repeat yourself" or "duplication is excellent". Here we go with the Euler's idendity. For the 3. Three. Times.

$$ f(b) = -e^{i\pi} + i^{1234567 >> 13 >> \left(-e^{i\pi} - e^{i\pi} - e^{i\pi}\right)!} \cdot b $$

f(b) = -(math.e**(1j * math.pi)).real + 1j**(1234567 >> 13 >> math.factorial(int((-math.e**(1j * math.pi) - math.e**(1j * math.pi) - math.e**(1j * math.pi)).real))) * b

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cursed_toggle-0.2.0.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cursed_toggle-0.2.0-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file cursed_toggle-0.2.0.tar.gz.

File metadata

  • Download URL: cursed_toggle-0.2.0.tar.gz
  • Upload date:
  • Size: 14.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for cursed_toggle-0.2.0.tar.gz
Algorithm Hash digest
SHA256 ef7a69c0d41ac8a87bba4279fbfb3de41455a459b7a9af9e14814bcafb82df3f
MD5 3f0e3062a42ae377faef6de7d87f46f9
BLAKE2b-256 4fa5f49bdf66c2117f5e3e70361c0d25c75d6b4680b19198aa369f1ab1a1d6df

See more details on using hashes here.

Provenance

The following attestation bundles were made for cursed_toggle-0.2.0.tar.gz:

Publisher: cd.yml on kvnglb/cursed-toggle

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file cursed_toggle-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: cursed_toggle-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for cursed_toggle-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 445f8f17c1556a1e9f946c1d28cbb4b8e91707856769eff94fc01af564ce0e57
MD5 7baf6ed86f88d59516dc0d9d75ba8d34
BLAKE2b-256 99950bdc2a57eb6e14b75fd00d015b5d2808089dcb782d96cf0825ca3092bff2

See more details on using hashes here.

Provenance

The following attestation bundles were made for cursed_toggle-0.2.0-py3-none-any.whl:

Publisher: cd.yml on kvnglb/cursed-toggle

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page