Wordy
Every text is a program. What a sentence does depends only on how long its words are.
2015 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 2 known programs · Test method
Run it
The idea
Wordy was designed in 2015, the specification says at 3am the week before finals, after .Gertrude. Any text cut into sentences by periods, question marks and exclamation marks is a valid program. For each sentence take the average word length, rounded, and count the words above it and below it. That ratio, reduced, picks one of 23 instructions from a table, and every other ratio is NOP. A sentence with 2 long and 4 short words is 1/2, which is ADD.
Read the story
Instructions are prefix expressions, so ADD adds the values of the two expressions after it. LITERAL takes the sentence after it as a number, the count of its words of exactly average length. The specification asks that no program ever crash, so every text runs, and most sentences do nothing.
The machine
| Ratios | Instructions |
|---|---|
| 0/1 | LITERAL, the next sentence as a number |
| 13/7, 2/3 | ASSIGN and VALUE of a variable |
| 2/1, 1/1 | LABEL and GOTO |
| 1/2, 5/9, 3/4, 4/1, 1/4, 2/9 | ADD, SUBTRACT, MULTIPLY, DIVIDE, MODULO, ABS |
| 1/5, 7/3, 9/5 | EQUAL?, LESS?, GREATER? |
| 11/17, 13/3, 5/13 | OR, AND, NOT |
| 4/7, 5/2 | INNUM, INCHAR |
| 15/14, 3/7 | OUTNUM, OUTCHAR |
| 1/0, 5/3 | RAND, EXIT |
There is no IF. OR and AND read their second argument only when they need it, so OR AND c a b picks a or b. A GOTO inside an expression moves the reading to its label, and the rest of the expression comes from there.
Example
Two sentences that echo a character.
Two sentences that echo a character. The first has 3 words longer than its average of 4 and 7 shorter, 3/7, OUTCHAR. The second has 5 words longer than 5 and 2 shorter, 5/2, INCHAR.
The specification also gives a pseudocode with the instruction names, and a number after each LITERAL. It runs as it is.
The specification works through a paragraph about GNU/Linux. Its three sentences come out as 2/4, 8/10 and 15/19, so ADD NOP NOP, which makes 0 and prints nothing. Its cat program is ten sentences of prose that read as LABEL NOP ASSIGN NOP OUTCHAR INCHAR GOTO NOT VALUE NOP. The specification proves Wordy Turing complete with rules that turn brainfuck into it, where variable 0 is the tape pointer and a first pass over the program defines every label.
Patterns it teaches
- Camouflage: a program reads as ordinary prose.
- Every text runs: any text is valid, and most sentences are NOP.
Further
See also
Also in Camouflage
Write your own in Run Convert a program from Wordy
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: wordy.
Command line
shib run wordy -e 'LABEL NOP ASSIGN NOP OUTCHAR INCHAR GOTO NOT VALUE NOP' --input 'hi'shib manual wordySource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/wordy.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org