Karvity
Karvity is an esolang created by User:Yayimhere based off of Noddity. Its was originally designed as a Church numeral version of Noddity, however did not end up as such. It uses two registers, but it also a loop counter for each loop.
Memory
Memory is held in two registers, with a pointer pointing to a specific one at all times.
Commands
Every command is held within these brackets, called the "Function":
[x]
where x is any single Noddity command repeated an unlimited amount of times. This specific Function will run all code after it first, and then the Noddity command specified within. This loops, incrementing its specific loop counter at the start of every loop, until the counter is more than or equal to the current register, checking at the start of every loop. If x does a GOTO(in any case), the program pointer goes to that command, and then back to the start of the program after that command has concluded. Different Functions looping counters cannot affect each other. Below are all Noddity commands:
| Command | Meaning |
|---|---|
s |
Switch between the two registers |
i |
Increment current register by 1 |
d |
Decrement current register by 1, Unless it decrements zero. In that case, jump to line n, where n is the number of times d is repeated.
|
n |
NOP |
g |
Unconditionally goto line n, where n is the number of times g is repeated.
|
h |
Halt. |
Demonstration
For the program:
[i] [dd]
the first command, [i] makes the program(in principle) into, using {} to represent the loop, the following code:
{
[dd]
i
}
[dd]
which then simplifies further:
{
{
i
{
dd
i
dd
}
dd
}
i
}
[dd]
so lets write this a little clearer:
{{i{ddidd}dd}i}
[dd]
lets take each loop. the first loop doesn't do anything at the start. on the next one however. we increment the first register, then we enter another loop and decrement it, then increment it, and decrement it again. since the register now is 0, so we do it again as the loop is checked at the start, and then do another decrement. this is a decrement on 0, we jump to the second line which interprets as:
{dd}
so we do a decrement on 0 again, jumping to the same line forever. as such, this is an infinite loop on 0.