I haven't played around with CC in a while, so I decided to do something with it that I have been into for ages;
Boolean Algebra.
You probably know what it is; it's just like redstone, it holds either the state true or false where true overwrites the false.
This is binary, and it's the core of every computer. You use it to make logic gates, so make a ALU, CPU, etc, the possibilies are endless.
So I wrote 2 small snippets of code that simulates the core of binary, the OR and NOT gate.
EDIT: Lignum gave me some better code; thanks
local function OR(a, B)/>/>
return a or b
end
local function NOT(a)
return not a
end
The OR gate will look at both inputs, and if either of them is true it will return true.
The NOT gate will return the opposite of the value of the input, so if a is true, it will return false and vice versa.
Using this, and only this, no if statements, no loops, no math. functions we can create everything, and that's what I wanted to share with you guys.
I'll keep this thread updated as I create more things with these 2 basic functions, and my goal will be to have a simple 8 bit CPU.
AND Gate:
Spoiler
local function OR(a, B)/>/>
return a or b
end
local function NOT(a)
return not a
end
local function AND(a, B)/>
return NOT(OR(NOT(a), NOT(B)/>))
end
local a = false
local b = false
local o = AND(a, B)/>/>/>/>
print(o)