const applyMethod = method => (obj, arg) => obj[method](arg);
Array.prototype.collect = function (f) {
return this
.map(f)
.reduce(applyMethod('concat'), []);
};
const bits = [1, 0];
const xor = (a, b) => a === b ? 0 : 1;
const results =
bits.collect(
x => bits.collect(
y => bits.collect(
z =>
xor(xor(x, y), z) === xor(x, xor(y, z))
)));
const isTruthy = Boolean;
console.log(results.every(isTruthy));