hcbf

From Esolang
Jump to navigation Jump to search

hcbf is an esoteric programming language conceived (and delivered by Caesarian section!) by Pierpaolo Giacomin (User:Yrz) at 15:39 CET, June 29th, 2005. It is a version of Brainfuck in which the memory is structured like a four-dimensional hypercube (a.k.a. a tesseract.)

Storage

Unlike Brainfuck's tape, hcbf's hypercube memory is defined to be bounded and cyclically closed, so that if one edge of the hypercube is reached, the data pointer "warps around" to the other edge, similar to Befunge. The size of memory is defined by the implementation; in the reference implementation, the hypercube size is 100x100x100x100. Each cell is byte-sized.

Because memory is a hypercube, the position of the data pointer can be given by four coordinates (X,Y,Z,T).

Instruction set

The hcbf instruction set is the same as the Brainfuck instruction set, with the addition of the @ instruction.

The @ instruction allows the program to change the axis in the hypercube along which the > and < instructions move the data pointer. Initially the pointer moves along the X axis. Executing @ once makes it move along the Y axis; another execution makes it move along the Z axis; another execution makes it use the T axis; then it goes back to the X axis.

A summary of the entire instruction set follows:

Instruction Description
@ Change direction of the pointer inc/dec.
> Increment the pointer.
< Decrement the pointer.
+ Increment the byte at the pointer.
- Decrement the byte at the pointer.
. Output the byte at the pointer.
, Input a byte and store it in the byte at the pointer.
[ Jump forward past the matching ] if the byte at the pointer is zero.
] Jump backward to the matching [ unless the byte at the pointer is zero.