NFuck

From Esolang
Jump to navigation Jump to search

NFuck

Basically this is brainfuck with N dimensions.

Architecture

NFuck extends the tape-like brainfuck memory to cater for n dimensions, where n, also being known as the “rank”, must be an integer with n ≥ 0, which will be specified by the user prior to the execution of the program.

The enhancement in dimensions perforce conditions the memory cell pointer's augmentation to an n-dimensional entity, typically a vector, whose elements assume signed integers without any constraints regarding the magnitude.

Commands

Proceeding from the more complicated memory model, several instructions have been adjusted to satisfy the new requirements. The commands < and > having vanished, instead the directional aspect has shifted to a new : operation that determines the direction mode, switching betwixt a motion along the positive and negative axis, while initialized to the former. The actual translation along the spanned space is realized with literal integers, known as the command n, expecting a non-negative sequence of digits which designate the dimension n to increment or decrement, depending upon the positive or negative configuration.

An aperçu concerning the commands shall now be provided:

Command Description
+ Add one to current cell
- Remove one from current cell
: Toggle negative/positive mode.
n Move 1 or -1 (depending on the mode) unit in dimension n
. Output the ASCII character associated with the current cell value
, Prompt the user for an ASCII character and store its code in the current cell
[ If current cell is zero then jump after the matching ]
] If current cell is nonzero then jump after the matching [

When running, the amount of dimensions should be conveyed to the interpreter.

Examples

Cat program

The following infinitely repeating cat program requires at least a rank of n=6:

5 ,.[,.]

See also

4DChess, a conceptually similar brainfuck derivative which restricts itself to four dimensions.

Interpreter

  • Common Lisp implementation of the NFuck programming language.