From Esolang
Jump to navigation Jump to search

1L_a, designed by Scott Feeney, is an esoteric programming language and the first member of the 1L family to have been implemented.

Rules and syntax

The memory is an array of bits (a tape), unbounded on the right. The leftmost cell is called TL0, and the next couple cells are called TL1 and TL2. The data pointer starts out pointing to TL2. The instruction pointer starts at the upper left corner of the source file moving down, and the program ends when the IP travels off the top or left side of the code. (Travelling off the right or the bottom results in undefined behavior.) The IP moves one cell at a time in the current direction, be that up, down, left, or right.

There are two symbols: spaces and everything else.

A space, if encountered by the IP moving left, moves the data pointer one cell to the left and then flips the bit at the data pointer. If a space is encountered by the IP moving up, the data pointer is moved one cell to the right. A space encountered while moving down or right is a nop.

Everything else forms a "turning wall" like the + in 2L. The instruction pointer moves backwards one space, then turns 90 degrees left if the current bit is 0 or right if the current bit is 1.

As in 2L, I/O is memory-mapped. Flipping the bit at TL0 causes an input or output operation, as follows:

If TL1 and TL2, then a 1 bit is output.
If TL1 and not TL2, then a 0 bit is output.
If not TL1, then a bit is input and saved in TL2.

The programmer should expect that asking for a bit of input will read and buffer a full byte from standard input and that no output will be done until 8 bits have been output, at which point a byte will be written. I/O is most significant bit first; e.g., to output an ASCII A (65, binary 01000001), one would output a 0, a 1, five 0's, and a 1.

Any type of comment can be written in to the source code, as long as it does not interfere with the instruction pointer.

1L_a is expected to be Turing-complete, but this has not been proven.


The 1L_a105 standard, published by the "1L_a Standardization Committee", subtly generalizes the language. It leaves implementation-defined how source code is represented on disk, saying only that the code is a 2D array of symbols. The symbol found in the top left corner of the array represents the GO instruction, while all other symbols in the alphabet represent the STOP instruction. The GO instruction works like the space, and the STOP like the turning wall, of pre-standard 1L_a.

In addition to letting the programmer use whatever characters he or she wants, this change also allows 1L_a to be programmed as a graphical language, using the color of a pixel as a symbol. An implementation exists that supports both text and graphical source code.

Example code

Here is an optimized program to print "A" in 1L_a, presented as graphical source code. Note that red is the GO instruction here, while black is the mandatory the STOP instruction. White pixels can be area for comments.

Enlarged view

Program to print "A" in 1L_a, as graphical source code.

Actual size

Program to print "A" in 1L_a, as graphical source code.


To write other ASCII characters, the following code "snippets" can be joined together to output individual bits. Note that one needs to print every 2nd bit seperately from the other bits. The basic idea is that all of the snippets start and end with the IP moving left, making connection rather easy. The data pointer also starts and ends exactly at TL2 every time, and every TL is set to 0 at the end (Except TL0, which would execute an I/O function when toggled. This is why there are seperate snippets for alternate I/O operations.).

For the 1st, 3rd, 5th, 7th output For the 2nd, 4th, 6th 8th output
Output 0 1L a1.png 1L a2.png
Output 1 1L a3.png 1L a4.png

Of course, one needs to start the progrem by making the pointer go left, and end the program by going out of the code area.

See also

External resources