mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-08-17 20:11:57 +02:00
fix typo
This commit is contained in:
@@ -53,25 +53,25 @@ 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
|
cell #1 at the end of the loop, move to cell #2, and then print out the value
|
||||||
in ASCII.
|
in ASCII.
|
||||||
|
|
||||||
Also keep in mind that the spaces are purely for readibility purposes. You
|
Also keep in mind that the spaces are purely for readability purposes. You
|
||||||
could just as easily write it as:
|
could just as easily write it as:
|
||||||
|
|
||||||
,[>+<-]>.
|
,[>+<-]>.
|
||||||
|
|
||||||
Try and figure out what this program does:
|
Try and figure out what this program does:
|
||||||
|
|
||||||
,>,< [ > [ >+ >+ << -] >> [- << + >>] <<< -] >>
|
,>,< [ > [ >+ >+ << -] >> [- << + >>] <<< -] >>
|
||||||
|
|
||||||
This program takes two numbers for input, and multiplies them.
|
This program takes two numbers for input, and multiplies them.
|
||||||
|
|
||||||
The gist is it first reads in two inputs. Then it starts the outer loop,
|
The gist is it first reads in two inputs. Then it starts the outer loop,
|
||||||
conditioned on cell #1. Then it moves to cell #2, and starts the inner
|
conditioned on cell #1. Then it moves to cell #2, and starts the inner
|
||||||
loop conditioned on cell #2, incrementing cell #3. However, there comes a
|
loop conditioned on cell #2, incrementing cell #3. However, there comes a
|
||||||
problem: at the end of the inner loop, cell #2 is zero. To solve this problem,
|
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.
|
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
|
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
|
brainfuck programs, or you can write a brainfuck interpreter in another
|
||||||
language. The interpreter is fairly simple to implement, but if you're a
|
language. The interpreter is fairly simple to implement, but if you're a
|
||||||
masochist, try writing a brainfuck interpreter… in brainfuck.
|
masochist, try writing a brainfuck interpreter… in brainfuck.
|
||||||
|
Reference in New Issue
Block a user