Sinisterly
Hello World - Printable Version

+- Sinisterly (https://sinister.li)
+-- Forum: Coding (https://sinister.li/Forum-Coding)
+--- Forum: Coding (https://sinister.li/Forum-Coding--71)
+--- Thread: Hello World (/Thread-Hello-World--42979)

Pages: 1 2 3


RE: Hello World - slbmeh - 09-04-2012

In brainfuck...

Code:
>++++++++[<++++++++>-]<++++++++.>+++++[<+++++>-]<++++.>+++[<+++>-]<--..+++.>+++++++++[<--------->-]<++.>+++++++[<+++++++>-]<++++++.>+++++[<+++++>-]<-.+++.>++[<-->-]<--.>+++[<--->-]<+.>++++++++[<-------->-]<---.

As said before, not very helpful...

The following would be slightly more helpful:

Brainfuck is a language similar to that of a turing machine. The syntax is as follows.
  • > - increase pointer position
  • < - decrease pointer position
  • + - increment pointer value
  • - - decrement pointer value
  • . - putchar
  • , - getchar
  • [ - while (pointer)
  • ] - end while

As always there are multiple ways to do hello world... I've primarily seen a single loop used to process all letters, I changed it up for my example.
  • Increase pointer position by 1, increment pointer value 8 times.
  • Start a loop.
  • Decrease pointer position by 1, increment pointer value 8 times.
  • Increase pointer position by 1, decrease pointer value 1 time.
  • Return to loop start.

This results in the loop running 8 times because we always end with our initially incremented value and decrement each time. This places a value of 64 in pointer 0.
  • Decrease pointer position by 1, increment pointer value by 8 (now 72)
  • Putchar(72) [ASCII "H"]

And so on through each character being presented in the string "Hello world!".