Beam

Beam is yet another two dimensional language thought of around mid-2010 by User:Feuermonster and implemented and published in 2012.


 * The start-up direction is right.
 * There is a beam which holds an 8bit unsigned value.
 * Also there is a store which can hold an arbitrary large positive value. If it drops below zero it's wrapped to 255.
 * Then there is an infinite amount of 8bit memory cells.
 * The implementation uses NUL (\0) if no character could be read from stdin.
 * Every character which is not an instruction is a NOP.

Instructions
> Set the direction to right < Set the direction to left ^ Set the direction to up v Set the direction to down + Increment the beam - Decrement the beam @ Output the beam as character : Output the beam as number / Redirect the control flow like this:

|  /        /---                |   (90 degrees to the left)

\ Redirect the control flow like this:

| -\   \      |

(90 degrees to the right)

! If the beam is not 0, reverse the control flow. (It bounces off the !) ? If the beam is 0, reverse the control flow. (It bounces off the ?) | Reverse the control flow if coming from a right/left-direction _ Reverse the control flow if coming from a up/down-direction H stop the program S store = beam L beam = store s memory[beam] = store g store = memory[beam] P memory[store] = beam p beam = memory[store] u If beam != store change direction to up n if beam != store change direction to down ` Decrement the store ' Increment the store ) If store != 0 change direction to left ( If store != 0 change direction to right r Read character from input

It should be noted, that 'u' and 'n' perform 32bit comparison: if the store exceeds 255 the comparison beam != store is always true since beam can not exceed 255. Lines are not padded to equal length. A compliant interpreter is not allowed to do this!

Reverse stdin
'>  rP   n ^!p''p!`>`p@ v            Hnp`<           ^ <

Painfully written by hand.

A faster version (thanks to User:Fizzie): >'p!rP(`)n>'p!`v ^       <    H(`p@p`)H H

Fastest version in the west (also thanks to User:Fizzie): v (>``v ! H(p`@`p)H P   H ' r ' P ! >^

Truth-machine
rS v >@<)  @

(Expects NUL or SOH from stdin.)

Hello
Prints

''v    >`++++++++++++++)++@v v++++++@-(++++++++++`<< >+@@+++@>-!'''>`++++++++++)v                      @+++<

Even / Odd
Reads from stdin and tests if the value (ascii value) is even or odd. If it is even, it prints a zero, else a one.

rv`< :u'< >-- u:

Cat
>r@nH ^ <

Compare
Reads in two ascii characters and prints out the smaller one. rP'Pr'P'P```v    < H @p'u``p< >p-P''p-P``pu'p@

Turing completeness
Brainfuck programs can be translated to Beam programs. This mechanism works with the 'u' instruction and marking cells to restore the store.

Brainfuck ,[>+>+<<-]++++++[><-]>[>.<]>.

Beam (translation with the bf2beam perl script) v              > v                                             > v                                       > v >rP>`p+P'p(`)uv>'>'p?-Pp+Pp+P````p-Pv>p++++++P>`p+P'p(`)uv>'>'p?-PpP``p-Pv>>`p+P'p(`)uv>'>'p?-Pp@``v>''p@H > '>'p?-P'                 ^                   > '>'p?-P'                  ^             > '>'p?-P'       ^ ^                                    <         ^                                     <   ^                          <

Beam constants
Constants to set the beam to a specific value (requires store to be zero.). This list is not complete. Help me!

Implementation

 * Java interpreter (DEADLINK)
 * Javascript interpreter with 2D trace (DEADLINK)
 * Online (HTML/Javascript) interpreter

Work in progress

 * Finding Beam constants.
 * Describing some techniques to program in Beam.
 * WeBeam (to program webpages).

Help is always welcome.

External resources

 * Brainfuck to Beam translation script