Todo
Todo is an esoteric programming language made by thejonymyster, where functions are called from a queue. Functions are defined and subsequently added to the queue, and can be called when on the top of the queue. The function which defines functions (function 0) is also on the queue. The program starts with only function 0 on the queue, and the variable 0 defined as the value 0.
Commands
Command | Description |
---|---|
f(a,b,c){your_code} | (a,b,c and {your_code} are optional) Move the last function in the queue to the beginning. Then, if it is not function 0, execute that function with arguments (a,b,c), ignoring the {your_code}. If it is function 0, then if and only if {your_code} is present, define a new function that does your_code and add it to the beginning of the queue. |
F(a,b,c){your_code} | (a,b,c and {your_code} are optional) Remove the last function in the queue. Then, if it is not function 0, execute that function with arguments (a,b,c), ignoring the {your_code}. If it is function 0, then if and only if {your_code} is present, define a new function that does your_code and add it to the beginning of the queue. |
loop(n){your_code} | Execute your_code n times. |
var(b){your_code} | Define a variable b to returned value of your_code. If nothing is returned, b is null. |
input() | Take one character of input code and return its character code. |
inc(b) | Increment b. |
print(b) | Print b as ascii. |
return(b) | Return b. If used outside of a function, print b and halt. |
Examples
Infinite loop
F(){f()}f()
Removes function 0 and defines a function that calls the end of the queue. Then, calls the function at the end of the queue, which calls the function at the end of the queue, which calls the function at the end of the queue...
Truth machine
By slabdrill#7381, two versions:
Takes ascii input 0 or 1:
F(b){print(b)loop(b){f(b)}} f(input())
Takes ascii input 48 or 49 ("0" and "1"):
var(i){input()} var(4){0}inc(4)inc(4)inc(4)inc(4) var(47){4}loop(4){loop(4){inc(47)inc(47)}inc(47)inc(47)}inc(47)inc(47)inc(47) var(c){0} var(r){0} loop(47){f(){}loop(c){f()}inc(c)} f(){inc(r)} loop(i){f()} print(i) loop(r){loop(47){F()}f(){print(i)f()}F()F()f()}
Fibonacci
By slabdrill#7381:
Doesn't halt, and prints in character codes rather than numbers.
var(a){0} var(b){0}inc(b) print(a) f(){loop(a){inc(b)}print(b)f()} F(){loop(b){inc(a)}print(a)f()} f()