Printscript 5
Printscript gets comments, input, logic and if, one version at a time, and still no loop.
A, 2019 · Turing complete: no · ●○○ easy · esolangs.org
Tested with 6 known programs · Test method
Run it
The idea
The esolangs.org user A kept adding to Printscript in 2019. Versions 5 to 8 each have their own C interpreter. Version 5 adds comments, version 6 reads input, version 7 adds and, or and not, and version 8 adds if. There is still no loop, so a program runs through once. This implementation runs version 8.
Read the story
Variables still hold one character. The logic works on characters less 48, so 0 is false and 1 is true, and the result goes back into the first variable as 0 or 1.
The machine
| Command | Does |
|---|---|
print "text" print x | Print a string or a variable |
set x c sev x y | Set x to the character c, or to the value of y |
- -[ ... ] | A comment to the end of the line, or up to ] |
input x | Read one character into x |
and x y or x y not x | Logic on 0 and 1, kept in x |
if x ... end | Run the block when x is above the character 0 |
else x ... end | Run the block when x is the character 0 |
else is not tied to an if. It is a second test of its own, which is why the specification writes the variable again. As in Printscript, print skips exactly one character after its name, whatever it is.
Example
The conditional prints the input when it is 1 and a message when it is 0.
The conditional prints the input when it is 1 and a message when it is 0.
Patterns it teaches
- Hostile design:
elserepeats its own test, andprintstill eats a character.
Further
See also
Also in Jokes
Write your own in Run Convert a program from Printscript 5
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: printscript-5.
Command line
shib run printscript-5 -e 'input a
print a' --input '3'shib manual printscript-5Source
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/printscript-5.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org