esolang

Turtlèd

A turtle walks a grid and writes characters. When the program ends, the grid is the output.

Destructible-Watermelon · Turing complete: unknown · ●●○ moderate

Tested with 4 known programs · Hello World on Try It Online: identical except the line end · Test method

Run it

Expected: Hello, World!

The idea

Turtlèd has no print command. A turtle starts on a grid of one cell, which holds *, and moves about writing characters into cells. The grid grows by a row or a column each time the turtle steps off it. At the end the whole grid is printed, with blank rows and columns trimmed from its edges. Loops test the character under the turtle, so the drawing itself is the program's memory.

The machine

Moves are relative to the way the turtle faces. This implementation follows the Python interpreter in the repository Destructible-Watermelon/Turtl-d, which is what TIO runs.

CommandDoes
r d l uStep right, down, left, up, as the turtle faces
< >Turn left, right
'cWrite c
"text"Write the text ahead, ending on its last character
@c then ,Set the char variable; write it
#text#, + -, .Set the string variable, move its pointer, write its character
digits, : ;Set a number; step that many times ahead or to the right
? !Read a number; a string
[cX]Repeat X while the cell is not c
{cX}Repeat X while the cell is c
(cX)Run X if the cell is c

$, ^ and % anywhere as commands keep the blank columns at the left, the blanks at the right, and the blank rows. Only the first line of the program runs.

Example

The second program writes a 3 by 3 square, snaking right, down, left, down and right.
Expected: ### ### ###
Expected: abc

The second program writes a 3 by 3 square, snaking right, down, left, down and right. The third writes each character of the string variable and steps on.

Patterns it teaches

Further

Also in Spatial (2D and up)

Write your own in Run Convert a program from Turtlèd

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run turtled -e ''\''\rd'\''\rd'\''\'
shib manual turtled

Source

Module
langs/tio/ports.js
Interpreter
langs/tio/turtled.js

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