|
 |
|
|
|
|
|
Brainf*ck
 |
|
 |
| |
Svip  |
|
I eat babies

Group: Retired Staff
Joined: Nov 12, 2001


|
Some of you might have heard of Brainf*ck, Brainf*ck is a programming language that only operates with 8 operators.
There are many guides and such you can find with google, but this topic is both a guide and a discussion of Brainf*ck.
Now, in order to understand the complex of Brainf*ck, you'll need to know how it works.
In Brainf*ck there is a pointer called 'The Pointer' or p, p points to what element in the array ( which is per standard 30,000 bytes ), the pointer can be moved around through the elements, and numbers can be added/subtracted.
Operators:
| < | moves the pointer one down or to the left, depends on how you see it, or you would say decreases | | > | moves the pointer the other way, or increases | | - | subtracts 1 from the respective element in the array | | + | adds 1 to the respective element in the array | | , | allows the user to type in a letter or string | | . | prints out the respetive element | | [ | starts a while loop that will go on untill the element is 0 or in C: while(*p != 0) | | ] | ends the while | In order to understand how you should output a character, you need to have a ASCII chart, I've written one for you that you can use which is written on the left side, so you can have your text editor open while looking at it.
| 32 | space | 64 | @ | 96 | ` | | 33 | ! | 65 | A | 97 | a | | 34 | " | 66 | B | 98 | b | | 35 | # | 67 | C | 99 | c | | 36 | $ | 68 | D | 100 | d | | 37 | % | 69 | E | 101 | e | | 38 | & | 70 | F | 102 | f | | 39 | ' | 71 | G | 103 | g | | 40 | ( | 72 | H | 104 | h | | 41 | ) | 73 | I | 105 | i | | 42 | * | 74 | J | 106 | j | | 43 | + | 75 | K | 107 | k | | 44 | , | 76 | L | 108 | l | | 45 | - | 77 | M | 109 | m | | 46 | . | 78 | N | 110 | n | | 47 | / | 79 | O | 111 | o | | 48 | 0 | 80 | P | 112 | p | | 49 | 1 | 81 | Q | 113 | q | | 50 | 2 | 82 | R | 114 | r | | 51 | 3 | 83 | S | 115 | s | | 52 | 4 | 84 | T | 116 | t | | 53 | 5 | 85 | U | 117 | u | | 54 | 6 | 86 | V | 118 | v | | 55 | 7 | 87 | W | 119 | w | | 56 | 8 | 88 | X | 120 | x | | 57 | 9 | 89 | Y | 121 | y | | 58 | : | 90 | Z | 122 | z | | 59 | ; | 91 | [ | 123 | { | | 60 | < | 92 | \ | 124 | | | | 61 | = | 93 | ] | 125 | } | | 62 | > | 94 | ^ | 126 | ~ | | 63 | ? | 95 | _ | 127 | | Another usefull ASCII charater is 10, which makes a breakline.
Now that you know what it prints, and what the operators is, you should grap a calculator, otherwise it will live up to it's name for you.
Let's go through some basics. In order understand the pointer, I've made some small codes that would help you:
This will go to '4 ( being element number 4 in the array ) and then add 3 to it. So it would somewhat simlar to this:
| CODE | Array: [0] [0] [0] [3] [0] ^ |
^ being the pointer.
In case we want to move that 3 to '3 instead of '4, it can be done with a loop command, which in this example should keep on untill '4 is 0;
Now, I am going to go much through this, if you want a more detailed tutorial, look here; http://neworder.box.sk/newsread.php?newsid=13065
Now, if you want a compiler for it, one can be caughted here: http://esoteric.sange.fi/brainf*ck/impl/compilers/ Note: You have to replace the * with u in the adress bar since this sh*tty forums edits 'fuck' to 'f*ck'.
I will start showing off a program that says; "Hi, svip":
| CODE | >+++++++++[<++++++++>-]<. [-]++++++++++[<++++++++++>-]<+++++. [-]++++[<++++++++++>-]<++++. [-]+++++[<++++++>-]<++. [-]+++++++++++[<++++++++++>-]<+++++. [-]+++++++++++[<++++++++++>-]<++++++++. [-]++++++++++[<++++++++++>-]<+++++. [-]+++++++++++[<++++++++++>-]<++. |
Discuss.
Credit to Segosa for telling me of Brainf*ck, and for the tutorial link. This post has been edited by Svip on Sunday, May 1 2005, 14:59
|
|
|
|
|
 |
|
 |
 |
|
 |
| |
Svip  |
|
I eat babies

Group: Retired Staff
Joined: Nov 12, 2001


|
| QUOTE (Segosa @ May 1 2005, 17:35) | | QUOTE (magical_trevor @ May 1 2005, 17:17) | | Is it me, or does this seem unnecessarily difficult? Nonetheless, it is pretty cool, but I don't think I'll be mastering it anytime soon. |
It's meant to be difficult. It's useless and it's meant to be a brain exercise, something to get you to use your brain in a way you haven't before. With a bit of imagination you can do quite a lot with it. | Well.
Not exactly, Urban Müller wanted to create the smallest compiler possible.
And 171 in bytes must be the smallest to date.
|
|
|
|
|
 |
|
 |
 |
|
 |
| |
segosa  |
|
Ghetto Star

Group: BUSTED!
Joined: May 15, 2002

|
| QUOTE (Svip @ May 1 2005, 17:46) | | QUOTE (Segosa @ May 1 2005, 17:35) | | QUOTE (magical_trevor @ May 1 2005, 17:17) | | Is it me, or does this seem unnecessarily difficult? Nonetheless, it is pretty cool, but I don't think I'll be mastering it anytime soon. |
It's meant to be difficult. It's useless and it's meant to be a brain exercise, something to get you to use your brain in a way you haven't before. With a bit of imagination you can do quite a lot with it. |
Well.
Not exactly, Urban Müller wanted to create the smallest compiler possible.
And 171 in bytes must be the smallest to date. | It isn't a compiler, it doesn't create a binary file, it simply outputs the C equivalent and then compiles with GCC. It is an interpreter.
|
|
|
|
|
 |
|
 |
 |
|
 |
| |
PatrickW  |
|
GTA Juggernaut

Group: Moderators
Joined: Jan 7, 2004



|
Thanx guys for bringing this up.... I really love these things
@Segosa, it really is a compiler. Compilers are pieces of software that transform the source-format into a target format (not neccesary executable). An Interpreter is a piece of software that reads a source format, and executes the instructions contained, which is here clearly not the case.
|
|
|
|
|
 |
|
 |
 |
|
 |
| |
Johnno  |
Posted: Thursday, May 5 2005, 09:49
|
WD&P Ogre

Group: Members
Joined: Sep 15, 2002



|
I've always been interested in esoteric programming languages, and might learn one shortly.
Brainf*ck certainly sounds interesting.
|
|
|
|
|
 |
|
 |
 |
|
 |
| |
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
Track this topic
Receive email notification when a reply has been made to this topic and you are not active on the board.
Subscribe to this forum
Receive email notification when a new topic is posted in this forum and you are not active on the board.
Download / Print this Topic
Download this topic in different formats or view a printer friendly version.
| |
 |
|
 |
|
|
|
|