IMG

 
IMG
IMG   IMG
  Welcome to GTAForums! Be sure to check out the Grand Theft Auto V Forum.

You are not registered! (If you are, click here to login) Registering is fast, free and easy and allows you to instantly reply to any topic on GTAForums.
Why wait? Click here to register your own unique username and become part of the ever-growing community!


( Log In | Register | Revalidate Validation E-mail )
Quick Log-In:
  IMG
       
>
  Reply to this topicStart new topicStart Poll

 Brainf*ck

 
Svip  
Posted: Sunday, May 1 2005, 14:49
Quote Post


I eat babies
Group Icon
Group: Retired Staff
Joined: Nov 12, 2001

dk.gif

XXXXX



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:

CODE
>>>+++


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;

CODE
>>>+++[<+>-]


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
Users WebsitePMAOLYahooICQPlayStation Network
  Top
 

 
magical_trevor  
Posted: Sunday, May 1 2005, 15:17
Quote Post


Propaganda Inc.
Group Icon
Group: Members
Joined: Nov 6, 2004

uk.gif

XXXXX



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.
PM
  Top
 

 
segosa  
Posted: Sunday, May 1 2005, 15:35
Quote Post


Ghetto Star
Group Icon
Group: BUSTED!
Joined: May 15, 2002

XXXXX



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.
PM
  Top
 

 
Svip  
Posted: Sunday, May 1 2005, 15:46
Quote Post


I eat babies
Group Icon
Group: Retired Staff
Joined: Nov 12, 2001

dk.gif

XXXXX



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.
Users WebsitePMAOLYahooICQPlayStation Network
  Top
 

 
segosa  
Posted: Sunday, May 1 2005, 16:06
Quote Post


Ghetto Star
Group Icon
Group: BUSTED!
Joined: May 15, 2002

XXXXX



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.
PM
  Top
 

 
PatrickW  
Posted: Tuesday, May 3 2005, 19:45
Quote Post


GTA Juggernaut
Group Icon
Group: Moderators
Joined: Jan 7, 2004

nl.gif

Member Award




Thanx guys for bringing this up....
I really love these things inlove.gif

@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.

Users WebsitePM
  Top
 

 
Octember  
Posted: Wednesday, May 4 2005, 00:16
Quote Post


propaganda inc
Group Icon
Group: BUSTED!
Joined: Oct 29, 2004

anarchist.gif

XXXXX




>+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]
>++++++++[<++++>-] <.>+++++++++++[<++++++++>-]<-.--------.+++
.------.--------.[-]>++++++++[<++++>- ]<+.[-]++++++++++.

'nuff said.
PMMSN
  Top
 

 
G twenty-nine  
Posted: Wednesday, May 4 2005, 02:18
Quote Post


Location: /home
Group Icon
Group: Members
Joined: Apr 16, 2005

sf.gif

XXXXX



>+++++++++[<+++++++++>-]<++++++++.->+++++++[<+++>-]<.++++++.[-]>++++++++[<++++>-]<.++>+++++++++[<+++++++++>-]<.++.>+++++++++[<-->-]<.++++++++.[-]>++++++++[<+++++>-]<++++.>++++++++[<++++>-]<.[-]>+++++++++[<+++++++++>-]<++.>+++++++[<+++>-]<+.+++++++++.[-]>++++++[<++++++++>-]<--.
You suck, sir.

I think I got it right, but I didn't use the compiler and all...
PM
  Top
 

 
segosa  
Posted: Wednesday, May 4 2005, 06:37
Quote Post


Ghetto Star
Group Icon
Group: BUSTED!
Joined: May 15, 2002

XXXXX



QUOTE (G twenty-nine @ May 4 2005, 04:18)
>+++++++++[<+++++++++>-]<++++++++.->+++++++[<+++>-]<.++++++.[-]>++++++++[<++++>-]<.++>+++++++++[<+++++++++>-]<.++.>+++++++++[<-->-]<.++++++++.[-]>++++++++[<+++++>-]<++++.>++++++++[<++++>-]<.[-]>+++++++++[<+++++++++>-]<++.>+++++++[<+++>-]<+.+++++++++.[-]>++++++[<++++++++>-]<--.
You suck, sir.

I think I got it right, but I didn't use the compiler and all...

segosa@linuxbox bin $ ./a.out
Yms suck,LSir.
segosa@linuxbox bin $

tounge.gif
PM
  Top
 

 
G twenty-nine  
Posted: Wednesday, May 4 2005, 23:13
Quote Post


Location: /home
Group Icon
Group: Members
Joined: Apr 16, 2005

sf.gif

XXXXX



Aw, f*ck, well I was close for a first time, aye?
PM
  Top
 

 
Johnno  
Posted: Thursday, May 5 2005, 09:49
Quote Post


WD&P Ogre
Group Icon
Group: Members
Joined: Sep 15, 2002

au.gif

Member Award




I've always been interested in esoteric programming languages, and might learn one shortly.

Brainf*ck certainly sounds interesting.
Users WebsitePMMSN
  Top
 

 

1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)

0 Members:

Topic Options Reply to this topicStart new topicStart Poll
Search topic for posted by (exact match)



 
IMG IMG