Skip to content

Instantly share code, notes, and snippets.

@houzyk
Last active July 31, 2023 12:15
Show Gist options
  • Save houzyk/841362716e4085099aaed05aaea58ab4 to your computer and use it in GitHub Desktop.
Save houzyk/841362716e4085099aaed05aaea58ab4 to your computer and use it in GitHub Desktop.
to-return-or-not-to-return
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