DFA-er
Build a finite automaton out of dots and dashes, feed it input, and if it says yes it shows the way it came.
Largejamie, 2021 · Turing complete: no · ●○○ easy · esolangs.org
Tested with 4 known programs · Test method
Run it
The idea
Largejamie made DFA-er in March 2021. A program written with only ., -, 0, 1 and ! builds a deterministic finite automaton whose states are named by binary numbers, and then runs input through it. The output is the walk itself. If the automaton ends in an accepting state, every state it passed through, the start too, comes out as the character with that code. So the names of the states are the text, and the input picks the walk.
Read the story
It has exactly the power of a finite automaton, and no more.
The machine
Before the first !.
| Code | Does |
|---|---|
.b. | Make a failing state named b |
..b. | Make an accepting state named b |
-a-b- | From the state made last, go to state b on the symbol a |
After the !.
| Code | Does |
|---|---|
.a. | Feed the symbol a |
- | Read a line and feed each character as its code |
The first state made is the start. An empty number is 0, so .. feeds 0 and --- is a move on 0 to state 0. If a symbol has no move, or the walk ends in a failing state, nothing is printed. Every other character is a comment.
Example
The Hello, world! feeds 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2 and 0.
The Hello, world! feeds 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 2 and 0. From l a 0 leads back to l, a 1 to o and a 2 to d, and the walk from H to the accepting ! spells the greeting.
The start is >, 111110. Any number of a, 1100001, lead to the accepting state a. A b has no move, so a word with a b in it prints nothing.
The binary cat works the same way with states 48 and 49 for 0 and 1. Its start state is named 0, so what it prints begins with a NUL.
Further
Ideas it shows
See also
Also in Turing tarpits
Write your own in Run Convert a program from DFA-er
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: dfa-er.
Command line
shib run dfa-er -e '.0.
-110000-110000-
-110001-110001-
..110000.
-110000-110000-
-110001-110001-
..110001.
-110000-110000-
-110001-110001-
!
-' --input '0110'shib manual dfa-erSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/dfa-er.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org