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
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.
| Inside | Is |
|---|---|
| a number | That number, as a float |
| a name | The variable of that name, or 0 |
line | A line of input |
+ - * / ^ | Arithmetic; + also joins strings |
= <=> ! | Equal, compare, not |
out | Print 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)):
Drawn out, the first is (out (+ 3 4)):
^
/ \
/out\
-----^
/ \
/ + \
^-----^
/ \ / \
/ 3 \ / 4 \
----- -----
Patterns it teaches
- Two-dimensional control flow: the shape of the drawing is the parse tree.
- Camouflage: a functional language disguised as ASCII art.
Further
- The interpreter, in Ruby
See also
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-schemeSource
- Module
langs/tio/ports.js- Interpreter
langs/tio/pyramid-scheme.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language