DNA#
Brainfuck written as a double helix of base pairs.
Benni++, 2009 · Turing complete: yes · ●●○ moderate · esolangs.org
Tested with 6 known programs · Test method
Run it
The idea
Benni++ made DNA# in 2009 after the shape of the DNA molecule. Each command is four letters from A, C, G and T, and a program can be drawn as a twisting double helix, two letters to a line. The same program can be written as one line of letters, or in a symbol form that is easier to read. Besides brainfuck's eight commands it can copy, add, subtract, multiply and divide one register into another.
The machine
| Codon | Symbol | Does |
|---|---|---|
| ATAT ATGC | > < | Move right or left |
| ATTA ATCG | + - | Add or take one |
| GCAT GCGC | . , | Print or read a character |
| GCTA GCCG | [ ] | Loop as in brainfuck |
| TAAT TAGC TATA TACG CGAT | := += -= *= /= | Combine the register with a second one |
| CGGC CGTA | ~ ? | Print or read a number |
| CGCG | X | Nothing; three in a row print the program |
The second register of += and the others is chosen by the arrows right after it, counted from the current register, and the pointer stays where it is. With no arrows it is the register itself, so += doubles. The specification leaves the size of the cells open; they hold integers of any size.
Example
The Hello World makes 8 by adding twice and doubling twice, squares 7 to get 49 and doubles that.
The Hello World makes 8 by adding twice and doubling twice, squares 7 to get 49 and doubles that. It prints in lower case and without the comma, although the specification calls it Hello, world!. The second program is +++++*=~ in line form. It counts to 5, multiplies the register by itself and prints the number.
Further
Ideas it shows
See also
DNA# builds on Brainfuck.
Brainfuck derivatives
Cell-based
Write your own in Run Convert a program from DNA#
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: dna-sharp.
Command line
shib run dna-sharp -e 'XXX'shib manual dna-sharpSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/dna-sharp.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org