esolang

Beam

A beam of light carries one byte across a grid of mirrors, and a store beside it counts the loops.

Feuermonster, 2012 · Turing complete: yes · ●●○ moderate · esolangs.org

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

Run it

Expected: S

The idea

Feuermonster thought of Beam around 2010 and published it in 2012. The IP is a beam that holds an 8-bit value. There is no stack. Next to the beam sits the store, a counter that only goes up and down by one, and a row of memory cells the two can reach.

Read the story

Arithmetic is one step at a time, so constants are built with loops: put a count in the store, add to the beam, and let ) turn the beam back while the store is not 0.

The machine

CharDoes
> < ^ vSteer
/ \Mirrors
! ?Bounce back if the beam is not 0, or if it is 0
\| _Bounce a horizontal or a vertical beam
+ -Add one to the beam or take one
@ :Print the beam as a byte or as a number
rRead a byte into the beam (0 at the end)
S LStore = beam, beam = store
' ` | Add one to the store or take one
s gmemory[beam] = store, store = memory[beam]
P pmemory[store] = beam, beam = memory[store]
u nTurn up or down if beam and store differ
) (Turn left or right if the store is not 0
HStop

Lines are not padded, and a beam that leaves the characters of the program ends the run.

Example

Print a letter with plain counting, then Hello!, which builds each step with a store loop.

Print a letter with plain counting, then Hello!, which builds each step with a store loop.

Expected: Hello!

Read two bytes and print the smaller one, from the specification.

Expected: 7

Reverse the input. P writes each byte at memory[store] while the store counts up.

Expected: cba

Patterns it teaches

Further

Two-dimensional languages

Cell-based

Write your own in Run Convert a program from Beam

Implementation

JavaScript interpreter, source and command line

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

Command line

shib run beam -e '>r@nH
^  <' --input 'abc'
shib manual beam

Source

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

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

Source esolangs.org (CC0) · Edit on esolangs.org