Hexsp
Lisp in Hexspeak. Every program is a column of hex bytes and looks like a machine code dump.
Otakuto, 2018 · Turing complete: yes · ●●● hard · esolangs.org
Tested with 3 known programs · Test method
Run it
The idea
Otakuto made Hexsp in 2018. Underneath it is a small Lisp with lists, recursion and functions passed as values. On top every character is a byte written in hexadecimal. EE opens a bracket, 33 closes it, and 00 is a space. Names are made of bytes too, chosen as Hexspeak words. CA 70 is car, AD D0 is add, DE F2 2C is defunc and 37 17 E0 is write.
The machine
| Bytes | Lisp |
|---|---|
EE 33 | ( ) |
00 | A space |
55 01 22 01 | The numbers 1 and -1; more bytes are more base 256 digits |
77 | t |
99 | Quote the next item |
11 | The dot of a pair |
FF | Take the next byte as it is, inside a number or a name |
| any other bytes | A name, such as DE AD BE EF |
Built in are CA 70 car, CD 70 cdr, C0 25 cons, A7 03 atom, E9 eq, AD D0 add, 52 B0 sub, 5E 79 setq, 1F if, 92 07 E0 quote, DE F2 2C defunc, BE 91 20 begin and 37 17 E0 write. Only write prints, and it prints in hex bytes too. The specification leaves the byte order of long numbers open; the most significant byte comes first.
Example
The first is (write 1).
The first is (write 1). The second is (defunc 0F (01 02) (add 01 02)) and then (write (0F 1 2)), a function named 0F with two parameters named 01 and 02.
The sample adds the numbers from 1 to 100. It defines iota, which makes the list from 1 to 100, and fold, which folds add over it from 55 FF 00, an escaped 0.
5,050 is 13BA in hex, so write prints 55 13 BA.
Patterns it teaches
- Camouflage: a Lisp dressed as a hex dump.
- Encoding tricks: every bracket, space and name becomes a byte.
Further
See also
Functional paradigm
Write your own in Run Convert a program from Hexsp
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: hexsp.
Command line
shib run hexsp -e 'EE 37 17 E0 55 01 33'shib manual hexspSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/hexsp.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org