Last active
July 31, 2023 12:15
-
-
Save houzyk/841362716e4085099aaed05aaea58ab4 to your computer and use it in GitHub Desktop.
to-return-or-not-to-return
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 isAutological = (func, ...funcParams) => { | |
const funcReturnValue = func(...funcParams); | |
return Object.is(funcReturnValue, func); | |
} | |
const isHeterological = (func, ...funcParams) => { | |
return !isAutological(func, ...funcParams); | |
} | |
const anAutologicalFunc = () => anAutologicalFunc; | |
const aHeterologicalFunc = () => true; | |
// Test Cases | |
console.log("Test Cases - isAutological", { | |
should_be_true: isAutological(anAutologicalFunc), | |
should_be_false: isAutological(aHeterologicalFunc) | |
}); | |
console.log("Test Cases - isHeterological", { | |
should_be_true: isHeterological(aHeterologicalFunc), | |
should_be_false: isHeterological(anAutologicalFunc) | |
}); | |
// ! Paradox | |
// isAutological(isHeterological) | |
// isHeterological(isHeterological) | |
// isAutological(isAutological) | |
// isHeterological(isAutological) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment