From Esolang
Jump to navigation Jump to search

When I first read the memory is structured like a hypercube I thought you were talking about an hypercube in infinite dimensions. How about the following language:

  • The memory tape is stored into a hypercube. The cube's side is 2, yet an unbounded number of cells can be accessed because there are an infinite number of dimensions.
  • > change the axis * operates on / go to the next dimension
  • < change the axis * operates on / go to the previous dimension
  • * switch to the other cell in the current direction
  • + - . , [ ] usual brainfuck instructions

The current axis at the beginning of execution is X; using > change it to Y, Z, T, then to higher-dimensional axis with no names. Using < change from Y to X, from Z to Y, etc., and is a no-op if the current axis is X. In other words, in Hcbf every cell is referenced by a quadruplet (x, y, z, t) of unbounded integers; in hypercubed brainfuck, every cell is referenced by an infinite sequence (x0, x1, x2...), where every xn is either 0 or 1 (and the sequence is not so infinite, as for every cell there exists an integer N such that for every n > N, xn = 0). The current cell at the beginning of execution is (0, 0,...). Using * directly will make the current cell (1, 0, 0,...), and using it again will go back to (0, 0, 0...), and using > and < change the coordinate the * instruction will affect. For instance if a program starts with >>*>*, the current cell will be (0, 0, 1, 1, 0, 0...). --(this comment by Koen at 11:02, 7 October 2012‎ UTC; please sign your comments with ~~~~)

I was thinking something similar, with 256 dimensions each of length 256 so despite having 21024 cells it's not Turing complete (This exceeds the number of atoms in the universe by a considerable factor). But seeing your variation made me realise these are actually rather trivial.
Another way of representing all three versions is to give hcbf a traditional brainfuck tape and alter the commands slightly.

  •  >  Moves the pointer  N  cells right
  •  <  Moves the pointer  N  cells left
  •  @  Cycles the  N  between the values 1, 100 and 10000
There is also a slight adjustment for the wrapping behaviour, but this is basically how I would implement it.
This means that yours, specifically, ends up as simply flipping bits in the array index.

For the record this is my variation:

Command Description
> Move the pointer to the right along the current dimension (wrapping at 256 cells)
^ Move the pointer "up" the dimensions (wrapping at 256 dimensions)
+ Increment the memory cell under the pointer
- Decrement the memory cell under the pointer
. Output the character signified by the cell at the pointer
, Input a character and store it in the cell at the pointer
[ Jump past the matching ] if the cell under the pointer is 0
] Jump back to the matching [ if the cell under the pointer is nonzero
' Do the previous > or ^ command 254 more times.

This is a compile time convenience feature for a negative one step.

Rdebath (talk) 08:45, 1 November 2015 (UTC)