Turnstyle is a graphical esoteric programming language loosely inspired by Piet. Both encode programs as images, however, the similarities end at the syntax level.
Where Piet is really a stack machine in disguise, Turnstyle is an encoding of the (untyped) Lambda calculus. This allows for building more reusable images at a higher level of abstraction, while still keeping the specification small, making it relatively easy to develop new interpreters.
This repository contains the language specification, a reference implementation in Haskell, and a simple JavaScript implementation.
The cheatsheet below provides a high-level overview, for more details please consult the Turnstyle Language Specification.
The starting Turnstyle shape is outlined. Click on the examples to run them in the browser.
Prints an approximation of pi by comparing the circle to its diameter:
Uses a Y combinator (indicated by the red rectangle in the top left)
and continuation-passing style to implement the Unix rev
program.
Type lines into the terminal to revert them.
Of course, fixed-point combinators are a primitive tool necessary to compensate for the limitations of one-dimensional programming. In two-dimensional programs, we can implement recursion using a more visually intuitive approach. This program prints the sequence of natural numbers:
In roughly this order: