A boolean value interview question
pixelstech.net
pixelstech.net
return a ^ b ? c : a
return a == b ? a : c
Are expressing exactly the same idea- When A and B are identical, they will xor to 0, and otherwise something nonzero. Thus, xor can be thought of in general as a "!=" operator, provided booleans work like you'd expect in C. (defn at_least_2 [a b c]
(>= (count (filter true? [a b c])) 2))