爪哇8,得分:360 358 319 271 233(240-7)个字节
interface J<O>{O f(O x,O y,J...j);}J t=(x,y,j)->x;J f=(x,y,j)->y;J n=(x,y,j)->j[0].f(y,x);J a=(x,y,j)->j[0].f(j[1].f(x,y),y);J o=(x,y,j)->j[0].f(x,j[1].f(x,y));J x=(x,y,j)->j[0].f(j[1].f(y,x),j[1].f(x,y));J i=(x,y,j)->j[0].f(j[1].f(x,y),x);
这比我刚开始时想的要难得多implies
。无论如何,它都能正常工作。编辑:好的,不重复使用函数,而只是复制相同的方法就Java的字节数而言便宜很多。而且由于不使用任何函数,我也获得了-7分的全额奖励。
在线尝试。
说明:
// Create an interface J to create lambdas with 2 Object and 0 or more amount of optional
// (varargs) J lambda-interfaces, which returns an Object:
interface J<O>{O f(O x,O y,J...j);}
// True: with parameters `x` and `y`, always return `x`
J t=(x,y,j)->x;
// False: with parameters `x` and `y`, always return `y`
J f=(x,y,j)->y;
// Not: with parameters `x`, `y`, and `j` (either `t` or `f`), return: j(y, x)
J n=(x,y,j)->j[0].f(y,x);
// And: with parameters `x`, `y`, and two times `j` (either `t` or `f`), return:
// j1(j2(x,y), y);
J a=(x,y,j)->j[0].f(j[1].f(x,y),y);
// Or: with parameters `x`, `y`, and two times `j` (either `t` or `f`), return:
// j1(x, j2(x,y))
J o=(x,y,j)->j[0].f(x,j[1].f(x,y));
// Xor: with parameters `x`, `y`, and two times `j` (either `t` or `f`), return:
// j1(j2(y,x), j2(x,y))
J x=(x,y,j)->j[0].f(j[1].f(y,x),j[1].f(x,y));
// Implies: with parameters `x`, `y`, and two times `j` (either `t` or `f`), return:
// j1(j2(x,y), x)
J i=(x,y,j)->j[0].f(j[1].f(x,y),x);