esolang

'129'

One data structure, two symbols, nine operations. Everything, the program too, is a stack of stacks.

TonyBrown148, 2021 · Turing complete: yes · ●●● hard · esolangs.org

Tested with 3 known programs · Test method

Run it

Expected: cat

The idea

TonyBrown148 made 129 in 2021. The specification spells out the name as 1 kind of data, the stack, written with 2 symbols, ( and ), and 9 operations. A stack is a pair of braces around its items, and every item is itself a stack, so () is the empty stack and (()()) holds two of them. A number is the size of a stack.

Read the story

The operations are stacks too, each of its own shape. That makes a program data. A program can build a stack of operations on the main stack and run it, and that is the only way to loop. The specification says 129 can implement the SKI calculus, which makes it a Turing tarpit.

The machine

A program starts with the version stack (()(()())()), for version 0.2.0. Every character that is not a brace is a comment.

OperationDoes
((X))Insert the items X into the main stack
((())())Delete the top
((())(()()))Duplicate the top
((()(()))())Push a value into the stack on top
(((()()))(()(())))Pop a value out of the stack on top
(((()()))(()()))Release all items of the top stack
((((()))())(()))Run the top stack as a program
(()((()())))Input a character as a stack of that many empty stacks
(((()()))())Output the character whose code is the top stack's size

An operation that cannot be done stops the Run it is in, or ends the program.

Example

A cat inserts two copies of one small program.

A cat inserts two copies of one small program. The program reads a character, prints it, duplicates the copy that is left and runs it. At the end of the input the read fails, and every Run stops in turn.

Printing needs a stack of the right size. Inserting a stack of 72 empty stacks and putting it out prints H.

Expected: H

Patterns it teaches

  • Turing tarpit: two symbols, and the specification says the SKI calculus fits in them.
  • Stack machines: with stacks as the only values.
  • Code as data: an operation is a stack like any other, built and run.

Further

Stack-based

Write your own in Run Convert a program from '129'

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: 129.

Command line

shib run 129 -e '(()(()())())((((()((()())))(((()()))())((())(()()))((((()))())(())))((()((()())))(((()()))())((())(()()))((((()))())(())))))((((()))())(()))' --input 'cat'
shib manual 129

Source

Module
langs/wiki/ports.js
Interpreter
langs/wiki/129.js

Docs: Kernel instructions · The .shib format · Command line · Adding a language

Source esolangs.org (CC0) · Edit on esolangs.org