Re:Ask HN: What's the largest amount of bad code you have ev...
by exikyut on Wednesday November 14, 2018 @05:52AM
(#18448959)
What sorts of techniques did they use? I'm very curious to see/hear examples.
[ Parent
| on HN ]
Re:Ask HN: What's the largest amount of bad code you have ev...
by brianpgordon on Wednesday November 14, 2018 @07:53AM
(#18449463)
function isTrue(v) {
var result;
result = v;
if (!isFalse(result == true)) {
return result;
} else {
return isFalse(result);
}
}
function isFalse(v) {
var result;
result = v;
if (!isTrue(result == true)) {
return isFalse(result); // Tail recursion so this is fine.
} else {
return result;
}
}
if (isTrue(myBool) == true) { // TODO: Could this be refactored to isTrue(isTrue(myBool))?
return true;
} else if (isTrue(isFalse(myBool))) {
return false;
} else if (isFalse(isTrue(myBool))) {
return false;
} else {
return isFalse(isFalse(myBool));
}
Re:Ask HN: What's the largest amount of bad code you have ev...
by strikelaserclaw on Wednesday November 14, 2018 @10:46AM
(#18450707)
i hope to god that this is just code you made up to be facetious.
Re:Ask HN: What's the largest amount of bad code you have ev...
by brianpgordon on Wednesday November 14, 2018 @11:06AM
(#18450884)
Haha, yes I made it up. The infinite recursion should have been a dead giveaway :P
There's also a bug on line 7 that I didn't notice - it should be isTrue rather than isFalse. I can't edit the comment anymore to fix it.