diff options
author | Adam Bard <github@adambard.com> | 2013-09-04 09:13:26 -0700 |
---|---|---|
committer | Adam Bard <github@adambard.com> | 2013-09-04 09:13:26 -0700 |
commit | d3ee747153b55a69ccd1bbddc769b5bbf9cbb38a (patch) | |
tree | 05a30410c4a16c4a667a9f0498eaa143aa5a7ef1 /brainfuck.html.markdown | |
parent | 7694dddf06ec2cbb25ca8cc8720215a2f31908bf (diff) | |
parent | d3ccd75c999d68a68fe82a61d1cb871b4d99a6e3 (diff) |
Merge pull request #303 from mathiasbynens/patch-1
brainfuck: A few corrections
Diffstat (limited to 'brainfuck.html.markdown')
-rw-r--r-- | brainfuck.html.markdown | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/brainfuck.html.markdown b/brainfuck.html.markdown index 2b7ce4db..9282381f 100644 --- a/brainfuck.html.markdown +++ b/brainfuck.html.markdown @@ -1,11 +1,12 @@ --- language: brainfuck contributors: - - ["Prajit Ramachandran", "http://prajitr.github.io"] + - ["Prajit Ramachandran", "http://prajitr.github.io/"] + - ["Mathias Bynens", "http://mathiasbynens.be/"] --- -Brainfuck is an extremely minimal programming language (just 8 commands) and -is Turing complete. +Brainfuck (not capitalized except at the start of a sentence) is an extremely +minimal Turing-complete programming language with just 8 commands. ``` Any character not "><+-.,[]" (excluding quotation marks) is ignored. @@ -27,7 +28,7 @@ There are eight commands: [ and ] form a while loop. Obviously, they must be balanced. -Let's look at some basic Brainfuck programs. +Let's look at some basic brainfuck programs. ++++++ [ > ++++++++++ < - ] > +++++ . @@ -45,21 +46,18 @@ print cell #2's value. 65 is 'A' in ASCII, so 'A' is printed to the terminal. , [ > + < - ] > . -This program reads a character from the user input, copies the character into -another cell, and prints out the same character. - -, reads in a character from the user into cell #1. Then we start a loop. Move -to cell #2, increment the value at cell #2, move back to cell #1, and decrement -the value at cell #1. This continues on until cell #1 is 0, and cell #2 holds -cell #1's old value. Because we're on cell #1 at the end of the loop, move to -cell #2, and then print out the value in ASCII. +This program reads a character from the user input and copies the character into +cell #1. Then we start a loop. Move to cell #2, increment the value at cell #2, +move back to cell #1, and decrement the value at cell #1. This continues on +until cell #1 is 0, and cell #2 holds cell #1's old value. Because we're on +cell #1 at the end of the loop, move to cell #2, and then print out the value +in ASCII. Also keep in mind that the spaces are purely for readibility purposes. You -could just as easily write it as +could just as easily write it as: ,[>+<-]>. - Try and figure out what this program does: ,>,< [ > [ >+ >+ << -] >> [- << + >>] <<< -] >> @@ -73,7 +71,7 @@ problem: at the end of the inner loop, cell #2 is zero. To solve this problem, we also increment cell #4, and then recopy cell #4 into cell #2. ``` -And that's Brainfuck. Not that hard, eh? For fun, you can write your own -Brainfuck programs, or you can write a Brainfuck interpreter in another +And that's brainfuck. Not that hard, eh? For fun, you can write your own +brainfuck programs, or you can write a brainfuck interpreter in another language. The interpreter is fairly simple to implement, but if you're a -masochist, trying writing a Brainfuck interpreter... in Brainfuck. +masochist, try writing a brainfuck interpreter… in brainfuck. |