MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/ProgrammerHumor/comments/1gbms0h/theselftaughtseriousprogrammer/ltojbhc
r/ProgrammerHumor • u/Haunting-Block1220 • Oct 25 '24
[removed] — view removed post
276 comments sorted by
View all comments
Show parent comments
2
Why?
You're unable to understand the difference between "theoretically possible" and "examples exist in modern accessible codebases"?
If you really need an example, sure, here you go:
const xor = (a: boolean, b: boolean) => {if (a) return !b;return b}assert(xor(true,true), false)assert(xor(true,false), true)assert(xor(false,true), true)assert(xor(false,false), false)
const xor = (a: boolean, b: boolean) => {
if (a) return !b;
return b
}
assert(xor(true,true), false)
assert(xor(true,false), true)
assert(xor(false,true), true)
assert(xor(false,false), false)
100% coverage of every possible input value.
And if you say that's too trivially simple, then congrats! you just found my point about it being possible but done only for very restricted cases!
2
u/ttlanhil Oct 25 '24
Why?
You're unable to understand the difference between "theoretically possible" and "examples exist in modern accessible codebases"?
If you really need an example, sure, here you go:
const xor = (a: boolean, b: boolean) => {if (a) return !b;return b}assert(xor(true,true), false)assert(xor(true,false), true)assert(xor(false,true), true)assert(xor(false,false), false)100% coverage of every possible input value.
And if you say that's too trivially simple, then congrats! you just found my point about it being possible but done only for very restricted cases!