Last active
January 13, 2023 23:52
-
-
Save Slackwise/6c469b0fbe99ff205a649f2b401294a5 to your computer and use it in GitHub Desktop.
Function definition modeling Schrodinger's Cat.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const cat = { | |
get state() { | |
delete this.state; | |
this.state = Math.random() >= 0.5 ? 'Alive' : 'Dead'; | |
return this.state; | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cat.state; // "Quantum Wavefunction Collapse" - the function replaces itself with the result of its computation | |
cat.state; // All future calls will return a static value and not a function | |
cat.state; | |
cat.state; | |
cat.state; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment