@justyy ‘s series of Logits Tests:
We have implemented the DECR function in last series using the only four keywords in this tiny programming language. This post, you will need to implement the SUBT function which takes two parameters and subtract one from the other i.e. X-=Y
In C++, you can probably implement this using a LOOP.
void subt(unsigned int &x, unsigned int y) {
for (int i = 0; i < y; i ++) {
x --;
}
}
We take one from X variable Y times and the variable X is a reference variable in C++. If we translate this into this language, here it comes:
SUBT(X, Y) {
LOOP(Y) {
DECR(X) // DECR has been implemented, so we can use it.
}
}
As you see, complex functions are built upon simple instructions namely ASGN, LOOP, INCR and ZERO. We are going to explore more in the next coming series, please be patient!
Everything about Logic(s)
- A Tiny Logic Puzzle about Truth and Lies
- Introduction to Logic Tests Series
- The Halting Problem and Its Paradoxical Cousins: When Logic Looks at Itself
- Logic Tests Series #2: Decr
- Logic Tests Series #3: Subt
- What is Moravec's Paradox?
–EOF (The Ultimate Computing & Technology Blog) —
239 wordsLast Post: SteemSQL Tutorial: How to Get Historic Posts of Today on SteemIt?
Next Post: SteemSQL Tutorial: What is Your Monthly Income on Steemit?