ZeptoBasic
Eight commands, six arithmetic words, and arrays that are only variables with a dot in their name.
nooodl, 2012 · Turing complete: yes · ●○○ easy · esolangs.org
Tested with 3 known programs · Test method
Run it
The idea
nooodl designed ZeptoBasic in December 2012 as a minimal BASIC, and its article carries the whole interpreter, 33 lines of Python. A program is one command per line. There are two kinds of value, whole numbers and strings in double quotes, and any other word is a variable. There are no expressions. Arithmetic is a command that changes a variable in place, so mul acc n multiplies acc by n.
Read the story
Arrays come for free. put a 3 15 stores 15 in the variable named a.3, and get j a i reads the variable a. followed by the value of i.
The machine
| Command | Does |
|---|---|
label name | Mark this line |
goto name | Jump to the label |
set var value | Set a variable |
print value | Print it and a line feed |
input var "prompt" | Print the prompt and read a line into the variable |
if v1 cmp v2 name | Jump to the label when lt le eq ne gt or ge holds |
get var a index | Set var to the variable a.index |
put a index value | Set the variable a.index |
add sub mul div mod pow var value | Change var by the value |
Adding two strings joins them and multiplying a string by a number repeats it. As in Python 2, numbers are whole and division rounds down. The interpreter reads an input line the way it reads a word of the program, so "hi" gives a string, 42 a number and a variable's name that variable's value.
Example
The factorial prints its prompt, multiplies acc by 5, 4, 3, 2 and 1, and stops when n reaches 0.
The factorial prints its prompt, multiplies acc by 5, 4, 3, 2 and 1, and stops when n reaches 0.
The array example stores five numbers in a.0 to a.4 and prints their squares.
Patterns it teaches
- Turing completeness: the specification proves it with a converter from brainfuck, which keeps the tape in the 300 variables
tape.0totape.299.
Further
See also
Also in Turing tarpits
Write your own in Run Convert a program from ZeptoBasic
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: zeptobasic.
Command line
shib run zeptobasic -e 'print "Hello, world!"'shib manual zeptobasicSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/zeptobasic.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org