| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
local function nand(x,y,z) |
| 15 |
z=z or 2^16 |
| 16 |
if z<2 then |
| 17 |
return 1-x*y |
| 18 |
else |
| 19 |
return nand((x-x%z)/z,(y-y%z)/z,math.sqrt(z))*z+nand(x%z,y%z,math.sqrt(z)) |
| 20 |
end |
| 21 |
end |
| 22 |
function math_not(y,z) |
| 23 |
return nand(nand(0,0,z),y,z) |
| 24 |
end |
| 25 |
function math_and(x,y,z) |
| 26 |
return nand(math_not(0,z),nand(x,y,z),z) |
| 27 |
end |
| 28 |
function math_or(x,y,z) |
| 29 |
return nand(math_not(x,z),math_not(y,z),z) |
| 30 |
end |
| 31 |
function math_xor(x,y,z) |
| 32 |
return math_and(nand(x,y,z),math_or(x,y,z),z) |
| 33 |
end |