Printscript 9
Printscript finally loops, and learns to count in character codes.
A, 2019 · Turing complete: unknown · ●○○ easy · esolangs.org
Tested with 4 known programs · Test method
Run it
The idea
The esolangs.org user A went on with Printscript and Printscript 5 in 2019. Version 9 adds while; the specification says it had a problem that version 10 fixed, without saying what. Version 11 adds pint, which prints a character's code as a number, inc, and .. to join prints. Version 12 adds add, sub, mul, div and mod. This implementation runs version 12.
Read the story
A variable still holds one character, so the arithmetic works on character codes. set a ! gives a the code 33, and inc a ! adds 33 more.
The machine
Everything from Printscript 5 stays, comments, input, logic and if included.
| Command | Does |
|---|---|
while x ... end | Repeat the block while x is above the character 0 |
pint x | Print the code of x as a number |
inc x c | Add the code of the character c to x |
add sub mul div mod | The same form as inc, with the other operations |
print "a" .. "b" | Print one more string or variable |
The specification gives no example of the version 12 words and calls them similar. They take a character the way inc does, and every result stays between 0 and 255.
Example
The truth machine prints its input once and then loops while it is 1.
The truth machine prints its input once and then loops while it is 1. On 0 the loop never starts.
A loop ends when its variable drops to 0. not does that on the first pass.
Patterns it teaches
- Hostile design: numbers exist only as the codes of the characters you can type.
Further
See also
Also in Jokes
Write your own in Run Convert a program from Printscript 9
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: printscript-9.
Command line
shib run printscript-9 -e '-pint example
set a !
pint a'shib manual printscript-9Source
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/printscript-9.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org