Math Is Fun Forum
  Discussion about math, puzzles, games and fun.   Useful symbols: √ ∞ ≠ ≤ ≥ ≈ ⇒ ∈ Δ θ ∴ ∑ ∫ π -

Login

Username

Password

Not registered yet?

Post a reply

Go back

Write your message and submit
:) :| :( :D :o ;) :/ :P :lol: :mad: :rolleyes: :cool: | :dizzy :eek :kiss :roflol :rolleyes :shame :down :up :touched :sleep :wave :swear :tongue :what :faint :dunno
Options

Go back

Topic review (newest first)

random_fruit
2009-01-03 08:18:34

The reason why brainf*ck is such a nasty programming language is that it doesn't use assembler style nmemonics.  A very long time ago I learnt a language called "CESIL" which is documented on the web.  See http://www.obelisk.demon.co.uk/cesil/  The power of the languages is similar, but the programmer-hostile form of the programs means it is really hard to read.

Computer science has a similar beast named "Turing Machine" and a theory (theorm?) which says that if a program can be written it can be written for a Turing Machine.  Look here: http://en.wikipedia.org/wiki/Turing_machine for some more details.

As a sage put it, there's nothing new under the sun.

MathsIsFun
2008-11-06 22:09:56

I read about it a few years ago, and was impressed by it's illegibility dizzy (...however I can see that "..+++." prints "llo", or at least some double letter followed by a letter three positions ahead!)

But it is impressive that it can do so much with so little, and so illustrates the fundamentals of programming. Anything else is just to make life easier!

All_Is_Number
2008-11-06 20:15:09

brainf***? It is an unfortunately (albeit accurately) named Turing complete language with only eight single character commands:

.  ,  <  >  [  ]  +  -

The language assumes (at least) a 30,000 element array, initialized to zero, and a moveable pointer, which is always pointing at a single element of the array.

>  moves pointer forward one position, relative to current position

< moves pointer back one position, relative to current position

+  increments value of array element in pointer's current position one unit

-  decrements value of array element in pointer's current position one unit

[  begins a "while value of element at current pointer position ≠ 0" loop

]  represents the end of the loop structure

. outputs ascii character associated with the value of element in current pointer position

, accepts ascii value of a single character as input and assigns that value to element at current position


Any character other than these eight, including spaces and new lines, is a comment.

brainf*** (<- not capitalized) is a Turing complete programming language. If a problem has a solution that can be calculated, given sufficient memory and time (and/or processing power), any Turing complete language , including brainf***, can be used to do the calculations. Compilers smaller than 200 bytes have been written for the language.

Here is an uncommented version of Hello World! in brainf***, ending in a new line (from Wikipedia):

Code:

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

A couple years ago, I wrote a brainf*** program that printed out the first 43 (I think) numbers of the Fibonacci sequence, without reusing anyone else's code. Due to hardware or compiler limitations (can't recall which) anything beyond that would have been inaccurately calculated. I'll see if I can't dig up the code.

Is anyone up to the challenge of writing a program in brainf***? Post them here. smile

Board footer

Powered by FluxBB