Penguin
Annotated edit history of Brainf*ck version 16, including all changes. View license author blame.
Rev Author # Line
16 AristotlePagaltzis 1 An interesting ProgrammingLanguage that is very easy to learn, but can get extremely confusing.
13 AristotlePagaltzis 2
16 AristotlePagaltzis 3 ''There's someone in my head,
4 <br> but it's not me.''
5
6 -- Pink Floyd, ''Brain damage''
10 GlynWebster 7
14 DanielCristofani 8 The language has 8 different commands. They use a nameless pointer to manipulate an array of at least 30000 cells, all initially set to 0. The pointer starts at the left end of the array.
10 GlynWebster 9
16 AristotlePagaltzis 10 +:
11 Increment the value of the current cell by 1
12 -:
13 Decrement the value of the current cell by 1
14 .:
15 Print the current cell as a character to standard output [stdout(3)]
16 ,:
17 Read a value from standard input to the current cell (these two use ASCII, with ten as newline) [stdin(3)]
18 >:
19 Move the pointer right one cell
20 <:
21 Move the pointer left one cell
22 [:
23 Start of a loop. This is essentially a while loop which will keep iterating while the pointer points to a nonzero cell.
24 ]:
25 End of the while loop. The sequence between the square brackets will get executed whilst the while loop executes.
10 GlynWebster 26
16 AristotlePagaltzis 27 As they say about [Perl]: ''There are many ways to skin a Camel''. This also holds true for [Brainf*ck].
15 AristotlePagaltzis 28
16 AristotlePagaltzis 29 Standard [Brainf*ck] thinks of every variable as an integer with a range of 0 through to 255. Different variables can be accessed by the < and > instructions. For example, <tt>++>++++<</tt> means:
15 AristotlePagaltzis 30
31 * Increment the current variable twice
10 GlynWebster 32 * Move to the next variable
15 AristotlePagaltzis 33 * Increment it variable 4 times
10 GlynWebster 34 * Move to the previous variable
35
36 After this bit of code, the variable we are currently referencing has a value of 2, and the next variable has a value of 4.
37
13 AristotlePagaltzis 38 !!! Examples
10 GlynWebster 39
13 AristotlePagaltzis 40 Here's a [HelloWorld] program:
10 GlynWebster 41
16 AristotlePagaltzis 42 <verbatim>
43 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++.
44 +++++++++++++++>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
45 ++++++++++++++++++++++++++++++++++++++++++++.+++++++..+++.>++++++++++++++
46 ++++++++++++++++++.<<.>.+++.------.--------.
47 >>++++++++++.
48 </verbatim>
10 GlynWebster 49
16 AristotlePagaltzis 50 A big archive of brainfuck programs and implementations is at [http://esoteric.sange.fi/brainfuck/].
10 GlynWebster 51
16 AristotlePagaltzis 52 You can read [more info | http://www.muppetlabs.com/~breadbox/bf/] [about the language | http://www.hevanet.com/cristofd/brainfuck/].
10 GlynWebster 53
13 AristotlePagaltzis 54 !!! Notes
14 DanielCristofani 55
16 AristotlePagaltzis 56 The language ignores any character in the program source code which is not a valid [Brainf*ck] command. This allows us to put comments in our code, as long as we make sure we do not accidentally use one of the language constructs in our comments. Or comments can be placed in a <tt>[]</tt> block, at a point in the code where the pointer is known to be at a zero cell.
57
58 GerwinVanDeSteeg is planning on writing his own [Compiler] and an interpreter for this language sometime in the near future. There are many available already on the WorldWideWeb; to find one, try [Google].
10 GlynWebster 59
16 AristotlePagaltzis 60 ''I've just written one. Insomnia has its own imperatives. Here you go: [brainfux0r.ml | http://www.wave.co.nz/~glyn/brainfux0r.ml]. It is written in [OCaml]. It has a [Compiler] (it compiles to [C]), an imperative interpreter and a functional interpreter. The functional interpreter has an infinite Turing tape as memory. I wrote and rewrote this program several times to try out various [OCaml] features. (I'm following the advice on StuffToCode.) --GlynWebster''
10 GlynWebster 61
11 GerwinVanDeSteeg 62 ----
13 AristotlePagaltzis 63 CategoryProgrammingLanguages, CategoryObfuscatedProgrammingLanguages

PHP Warning

lib/blame.php:177: Warning: Invalid argument supplied for foreach() (...repeated 5 times)