esolang

Pyramid Scheme

A Lisp in which every pair of brackets is drawn as a pyramid.

Conor O'Brien · Turing complete: yes · ●●○ moderate

Tested with 3 known programs · Hello World on Try It Online: identical · Test method

Run it

Expected: 7

The idea

Each pyramid has a ^ tip, / and \ sides and a bottom of -, with a word written inside. A pyramid whose tip touches the bottom left or bottom right corner of another one is its argument, so a call with two arguments is a pyramid standing on two smaller ones. The tips on the first line are the program's roots, evaluated left to right, and the whole thing reads like a Lisp expression tree drawn in ASCII.

The machine

Values are Ruby's integers, floats, strings, lists and nil. A float that is a whole number becomes an integer. This implementation follows the Ruby interpreter in Conor O'Brien's repository Pyramid-Scheme, which is what TIO runs; it leaves out arg and the fractions and complex numbers that ^ can make.

InsideIs
a numberThat number, as a float
a nameThe variable of that name, or 0
lineA line of input
+ - * / ^Arithmetic; + also joins strings
= <=> !Equal, compare, not
outPrint the arguments
chr " #A character, as text, back to a number
set do loop ?Assign, do while, while, if; arguments not evaluated first

When nothing has been printed with out, the value of the program is printed at the end.

Example

Drawn out, the first is (out (+ 3 4)):
Expected: 42

Drawn out, the first is (out (+ 3 4)):

  ^
 / \
/out\
-----^
    / \
   / + \
  ^-----^
 / \   / \
/ 3 \ / 4 \
----- -----

Patterns it teaches

Further

Also in Functional and concatenative

Write your own in Run Convert a program from Pyramid Scheme

Implementation

JavaScript interpreter, source and command line

A JavaScript interpreter, used in the browser and on the command line. Id: pyramid-scheme.

Command line

shib run pyramid-scheme -e '     ^
    / \
   / * \
  ^-----^
 / \   / \
/ 6 \ / 7 \
----- -----'
shib manual pyramid-scheme

Source

Module
langs/tio/ports.js
Interpreter
langs/tio/pyramid-scheme.js

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