Jump to content
Science Forums

Recommended Posts

Posted

Don't even think of editing that title, it is a name of a programming language i have learned about just recently, and it's soo appropriately named too.

 

Basic idea is this, in this language you work with data pointers, in a sort of, array if you will, there is an array of at least 30,000 bytes initialized at start, and the language has 2 streams of bytes that are connected to the keyboard and monitor, you work with ascii, and you can only do 8 things in this language:

> - increments data pointer

< - decrement data pointer

+ - increment byte

- - decrement byte

. - output value of the current location

, - accept one byte of input and write it to the current location

[ - if the data at the current pointer is zero instead of executing the next command, it jumps to the ]

] - if the data at the curent pointer is not zero, this will return one back to the [

{last two are used for looping}

 

so here's an example of code:

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

 

now you figure out what it does :QuestionM

 

well i formatted it for you, it could have easily looked like this, too

 

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

 

Posted

Name of thread is fine with, it kind of hits the nail on the head (not sure if this is an english saying or from another language I know...)

 

With help I figured out that it prints, actually deducted highlight post to see it, since the first print gives anB and the secon an r...:

Brain****

Posted

No my english was not clear, just higlight my post and told also what it prints, I did not want to spoil it for the others so I wrote in white color what it does...

Posted

here, actually for others that get anxious, here's a brain**** interpreter

 

/* Eric */main(s,i,j,k,c){char*p=malloc(s=1),*a=p+(*p=i=j=k=0)/* Bock */
;while(~(*a=getchar())&&(++a-p<s||(a=(p=realloc(p,s+s))+s)&&(s+=s))||(*a
=0));for(a=malloc(s=1),*a=0;(c=p[i])&&(c=='+'&&++a[j]||c=='-'&&--a[j]||c
=='>'&&(++j<s||(a=realloc(a,s+s))&&memset(a+s,0,s)&&(s+=s))||c=='<'&&j--
||c=='.'&&~putchar(a[j])||c==','&&~(a[j]=getchar()))|!strchr("><.,",c);i
++)while((c=='['&&!a[j]||c==']'&&a[j])&&(k+=(p[i]=='[')-(p[i]==']'))&&p[
i+=c/* Brainf*** */=='[']&&(/* worse than */i-=c==']'/* this sig! */));}

compile with gcc and then in order to interpret, do ./bf < prog.bf

i know it runs in cygwin, but no reason it should not work on actual nix ;)

Posted
Sanctus, it does print ;) that's what the dots indicate... you figure out what (even if you post ascii values it's major kudos for you :hihi: its a fun language though)
Fun? You call this a FUN language?

We have way different definitions of 'fun'.

My definition of 'fun' includes maximum raw power, with minimum input; and that input must look 'elegant' and esthetically pleasing.

 

PERL, with lots and lots of Regular Expressions. That's fun! :)

Posted

ofcourse i call this fun, it takes little to make a geek smile, it just has to be geekier then their current level of geekdom...

 

I am embarking on a project though, i want to write a brain**** compiler in brain**** to perhaps go to 8085 or x86 assembly... should be fun, also it would be another thing on my resumee so yeah...

 

Pyro, first of all learn Python, you want sheer awesomeness, that's a language for you (and mods for arbitrary precision math make it perfect for many many great and fun (your definition) applications)

 

I call brain**** fun because it forces one to think in logic that one normally can not grasp, thus making cool things in it is not only a challenge, but is, for lack of better term, fun.

Posted

Many a Perl people have been converted to the dark side, to Python ;) namely a good friend of mine, Adam, was a total perl zealot, he was convinced that he would never like Python, nor convert from Perl, he hated it for a week, and then all of a sudden, bam it made sense and became the best language in the world, he's a hardcore Python guru now, he wrote some genetic algorithms in it, he wrote a huge piece of code for package rollout and central management for gentoo, and he writes nearly all the code in python now :hihi:

Posted
now you figure out what it does :shrug:
I manually stepped through it outputting "Brain", so I'm guessing it outputs "Brain****". I'm also not stepping through it manually anymore, but writing a program to, as this is not activity fit for a human! :magic:
Posted
I manually stepped through it outputting "Brain", so I'm guessing it outputs "Brain****". I'm also not stepping through it manually anymore, but writing a program to, as this is not activity fit for a human! :shrug:
I guessed wrong!

 

It outputs: "Brain**** ****s with your brain :)"

 

Here's a Brain**** interpreter written in MUMPS:

[noparse]s D=$tr($j("",30000)," ",$c(0)),(DI,PI)=1 f  q:$e(P,PI)=""  x XLBF($e(P,PI)) ;XLBF:Brain**** language interpreter
s $e(D,DI)=$c($a(D,DI)+1),PI=PI+1 ;XLBF("+")
s $e(D,DI)=$c($a(D,DI)-1),PI=PI+1 ;XLBF("-")
r *R s $e(D,DI)=$c(R),PI=PI+1 ;XLBF(",")
w $e(D,DI) s PI=PI+1 ;XLBF(".")
s DI=DI-1,PI=PI+1 ;XLBF("<")
s DI=DI+1,PI=PI+1 ;XLBF(">")
s PI=PI+1 i '$a(D,DI) f PI=PI:1 q:$e(P,PI)?1(1"]",1"")  ;XLBF("[")
s PI=PI+1 i $a(D,DI) f PI=PI-2:-1 q:$e(P,PI)?1(1"[",1"")  ;XLBF("]")

r P,! x XLBF
++++++++++[>+++++>++++++++++>+++++++++++>+++>+<<<<<-]>++++++++++++++++.>>++++.<---.++++++++.>----.<---.>+++++++.<---.>----------.>++.<<+++.>++++++++++.<---.>----------.++++++++.>.<++++.<++++++.>---.<-.>>.<+++++.----------.++++++.---.>.<<------.>.<-.++++++++.>----.>.<<<--------.>>>+++++++++.>.
Brain**** ****s with your brain 
[/noparse]

Fun! :shrug:

 

Now, who wants to really get into the spirit of it, and write a Brain**** interpreter in Brain****? or that other programming classic, a Brain**** program that produces itself as output? :D

Posted

Craig, perhaps you didn't read my previous post, i am writing a brain**** compiler in brain**** (it will compile into x86 assembly) well or at least laying it out now. Since brain**** lack traditional control and decision structures, but i think i have finally figured out some magic to make it all work together :)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...