The brainfuck programming language is an esoteric programming language noted for its extreme minimalism. It implements a Turing-complete language.

brainfuck was created in 1993 by Urban Müller with the intention of designing a language which could be implemented with the smallest possible compiler.

The language consists of eight commands:


Cmd  Effect

—  ——

+    Increases element under pointer

–    Decrases element under pointer

>    Increases pointer

<    Decreases pointer

[    Starts loop, flag under pointer

]    Indicates end of loop

.    Outputs ASCII code under pointer

,    Reads char and stores ASCII under ptr


The equivalent C notation for brainfuck "+" is the following:

  ++*ptr

  It increments the current cell by 1,

The equivalent C notation for brainfuck "-" is the following:

  --*ptr

  It decrements the current cell by 1.

If you want to set a "B" char in the current cell of memory you shell increment the cell with 66 + (if the current cell value is 0). Now if you want to set the value of this cell to a "A" char you only need to add a "-", the following example prints "BA".

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.-.


The equivalent C notation for brainfuck ">" is the following:

  ++ptr

  New current cell is the next cell

The equivalent C notation for brainfuck "<" is the following:

  --ptr

  New current cell is the prevoius one.

If you want to set the first ten cell to "1" you can do the following:

+>+>+>+>+>+>+>+>+>+

 and now if you want to come back to the first cell you can do:

<<<<<<<<<<


The equivalent C notation for brainfuck "." is putchar(*ptr), while the equivalent C notation for brainfuck "," is the following:

*ptr=getchar();

The "," operator will be implemented in a next version of brainfucktory.


The equivalent C notation for brainfuck "[" and "]" is the following:

while(*ptr)

{

}

if you want to do the following:

i=10;

while(i){printf("%d",i); i--}

you can do:

++++++++++[.-]