Lines
/// with input. A \| is not a bar but the next character you type.
2015 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 4 known programs · Test method
Run it
The idea
Lines is /// with one exception. A /// program prints its plain characters and rewrites the rest of itself with /pattern/replacement/. In Lines the escape \| reads one character from the input at the moment the interpreter reaches it, and that character takes its place.
Read the story
In plain text, the character is printed. Inside a substitution it becomes part of the pattern or the replacement, and the substitution copies it through the rest of the program. Every /// program without a | runs the same in Lines.
The machine
The program is a string, read from the left.
| Next characters | Does |
|---|---|
\| | Read a character and use it here |
\c | The character c, never a command |
/pattern/replacement/ | Replace pattern in the rest of the program, again and again until it is gone |
| any other character | Print it |
The specification gives an interpreter in Java, and this implementation follows it. Each search starts again from the left, so a replacement that contains its own pattern never ends. The program stops when it runs out.
Example
The three programs from the specification.
The three programs from the specification. The first prints one character of the input.
The second reads x while it reads the replacement of /~/\|/, so the rest of the program, ~~, becomes xx. The third turns the rest into /q// and the character it read. That substitution removes a q and leaves anything else, so on q it prints nothing. On ~ both freeze, because /~/~/ replaces ~ with itself forever.
One read can fill many places.
Patterns it teaches
- String rewriting: one substitution command, now fed by the input.
- Self-modifying code: the input is written into the program that is still to come.
Further
- esolangs.org/wiki/Lines
- ///, the language it extends.
See also
String-rewriting paradigm
Self-modifying
Write your own in Run Convert a program from Lines
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: lines.
Command line
shib run lines -e '\|' --input 'a'shib manual linesSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/lines.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org