Corea
Plain text prints itself. Only what sits between quotes is code, and that code builds more text.
Conor O'Brien · Turing complete: unknown · ●●○ moderate
Tested with 6 known programs · Hello World on Try It Online: identical · Test method
Run it
The idea
Conor O'Brien made Corea as a successor to his earlier language Chaîne. A program is output by default: Hello, World! prints Hello, World!. A " switches to commands until the next " or ;, and the commands work on a stack of strings and on the output buffer.
Read the story
The most Corea-like feature is fields. F followed by a character stores the top of the stack under that character. When the program ends, every occurrence of that character in the buffer is replaced by the stored text. So a template like Hi, X! becomes a greeting once X is set.
The machine
The stack holds strings. Popping it when it is empty reads a line of input instead.
| Code | Does |
|---|---|
digits, 'c, `text` | Push a number, a character, a string |
> ; \|c | Append the top, or a character, to the buffer |
< @ | Push the buffer, clear it |
: \ & $ { } | Duplicate, swap, rotate, drop, top to bottom, bottom to top |
~ x L l | Join, repeat, reverse, length |
+ - * / ( ) | Whole numbers of any size |
h v H | Mirror: brackets and slashes flip |
r R | Replace text, replace a regular expression |
F f g | Store a field; replace fields now |
d ! | Run a string of commands n times, once |
C | One of ten constants; 4 is Hello, World! |
i I | Read a line as text, as a number |
At the end the fields are filled in and the buffer is printed. This implementation follows the Java interpreter at github.com/ConorOBrien-Foxx/Corea, which TIO runs. An error there ends the program before anything is printed, and so it does in this implementation.
Example
The third reads a line into field X, which then fills the template.
The third reads a line into field X, which then fills the template. The fourth mirrors (<: the text is reversed and each bracket turns around.
Patterns it teaches
- String rewriting: fields rewrite the output once the program ends.
- Code golf: text that does not need to be computed costs nothing.
Further
See also
Also in Golfing
Write your own in Run Convert a program from Corea
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: corea.
Command line
shib run corea -e '"4C>'shib manual coreaSource
- Module
langs/tio/ports.js- Interpreter
langs/tio/corea.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language