Parenthesis Hell
A Lisp with no atoms. There is nil, there are pairs, and a program is nothing but brackets.
2009 · Turing complete: yes · ●●● hard · esolangs.org
Tested with 6 known programs · Hello World on Try It Online: identical except the line end · Test method
Run it
The idea
Parenthesis Hell is a Lisp in which the only data are the empty list () and pairs. Code is data, so a program is a single nest of matching brackets; every other character is a comment.
Read the story
Without atoms there are no names, so a function is named by a value. () names quote, (()) names letrec, ((())) names car, and so on. A program can define its own functions with letrec and even give one the name of a built-in, which then hides it.
The machine
A program is one expression. It runs with the input as its argument, and its value is the output.
| Expression | Value |
|---|---|
() | The argument |
(() x...) | quote: (x...) unevaluated |
((()) bindings body...) | letrec: run the body with (name body...) bindings in scope |
(((())) x...) ((()()) x...) | car, cdr of the value of (x...) |
(((())()) a b...) | cons of the value of a and the value of (b...) |
((()()()) c t e...) | if c is not nil then t, else (e...) |
((((()))) x...) | eval: the value of (x...), run again |
Text is bits, eight to a byte. A 0 is written () and a 1 is an opening bracket closed at the very end, so the letter I, 01001001, is the list after the quote in (()()(()()(()()(())))). Input arrives in the same shape and the output is read back from it.
Example
The last two are one program.
The last two are one program. If the input is not nil it gives the input, otherwise it quotes the bits of I. The esolangs.org quine is a quine of values; run, it evaluates to exactly its own brackets.
Ideas it shows
See also
Also in Functional and concatenative
Write your own in Run Convert a program from Parenthesis Hell
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: parenthesis-hell.
Command line
shib run parenthesis-hell -e '()' --input 'cat'shib manual parenthesis-hellSource
- Module
langs/tio/ports.js- Interpreter
langs/tio/parenthesis-hell.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org