PRINTASKSWITCHINPUTCASEXGOTOACASEYGOTOBELSEGOTOC
The name is the whole language. Every line prints, asks, and jumps on the answer.
Rdococ · Turing complete: no · ●○○ easy · esolangs.org
Tested with 4 known programs · Test method
Run it
The idea
Rdococ made this language to give the Goto language better input and output. There is one instruction, and its name spells it out. Print a text, ask for a line of input, compare the line with two cases, or with none, and go to the line that matches. A program is a list of these lines, so each line is a state of a finite state machine. The longer example is a text adventure.
Read the story
Strings may only hold capital letters, the specification says, to add to the feel of the language. A program with a lower case letter anywhere is refused.
The machine
| Form | Does |
|---|---|
PRINT "T" ASK SWITCH INPUT CASE "A" GOTO x CASE "B" GOTO y ELSE GOTO z | Print T, read a line, go to x on A, y on B, z otherwise |
PRINT "T" ASK SWITCH INPUT ELSE GOTO z | Print T, read a line, go to z |
This implementation follows the Python in the specification. Lines count from 0, and a jump to a line that does not exist ends the run. Every text is printed with a line feed after it. The Python stops with an error when the input runs out; the run ends quietly at that point, with the same output.
Example
The Hello World goes back to line 0 after each answer, so it prints once for every line of input and once…
The Hello World goes back to line 0 after each answer, so it prints once for every line of input and once more.
A choice of two. GREEN matches neither case and asks again; BLUE goes to line 2, and line 3 does not exist, so the run ends.
The very bad RPG, five lines long, runs as written.
See also
Also in Jokes
Write your own in Run Convert a program from PRINTASKSWITCHINPUTCASEXGOTOACASEYGOTOBELSEGOTOC
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: printaskswitchinputcasexgotoacaseygotobelsegotoc.
Command line
shib run printaskswitchinputcasexgotoacaseygotobelsegotoc -e 'PRINT "HELLO WORLD!" ASK SWITCH INPUT ELSE GOTO 0'shib manual printaskswitchinputcasexgotoacaseygotobelsegotocSource
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org