NumSym
Digits and symbols on one stack, with the input handed over before the run starts.
Stiathirs the Protogen, 2022 · Turing complete: unknown · ●●○ moderate · esolangs.org
Tested with 5 known programs · Test method
Run it
The idea
Stiathirs the Protogen made NumSym in 2022. The name is short for NumberSymbol, because every command is a digit or a symbol. The input is not asked for during the run. It is a buffer given with the program, and reading past its end gives 0.
Read the story
A digit pushes only itself, so bigger numbers are built with arithmetic, and 72 is 98*. A loop tests the top of the stack without popping it, which is why the programs are full of ;. The specification presumes NumSym is not Turing complete.
The machine
| Command | Does |
|---|---|
0 to 9 | Push the digit |
^ | Push the next input byte, or 0 at the end |
! @ ; | Duplicate; reverse the stack; drop |
+ - * / % | Arithmetic on the top two, the top on the right |
< = > | Compare the top two, the top on the right; push 1 or 0 |
# $ | Pop and print as a number; as a character |
[ ] | Loop while the top is not 0 |
Example
The Hello World pushes every character, then a 0, reverses the stack and prints until it reaches the 0.
The Hello World pushes every character, then a 0, reverses the stack and prints until it reaches the 0.
The truth machine compares the input with 49, the code of 1. On 1 the loop prints 1 forever. On anything else the loop is skipped and the 0 is printed once.
The specification also has a FizzBuzz that loops 250 times and a 99 Bottles of Beer of 786 characters that it leaves unexplained. The song counts down to 1 bottle, takes it down and ends with no more bottles.
Patterns it teaches
- Stack machines: one stack, and a reverse to reach the bottom.
Further
See also
Stack-based
Write your own in Run Convert a program from NumSym
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: numsym.
Command line
shib run numsym -e '^[$^]' --input 'Cat!'shib manual numsymSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/numsym.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org