How does the Brainfuck Hello World actually work?

后端 未结 6 1523
长情又很酷
长情又很酷 2021-01-29 17:38

Someone sent this to me and claimed it is a hello world in Brainfuck (and I hope so...)

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


        
6条回答
  •  花落未央
    2021-01-29 18:24

    I think what you are asking is how does Brainfuck know what to do with all the code. There is a parser written in a higher level language such as Python to interpret what a dot means, or what an addition sign means in the code.

    So the parser will read your code line by line, and say ok there is a > symbol so i have to advance memory location, the code is simply, if (contents in that memory location) == >, memlocation =+ memlocation which is written in a higher level language, similarly if (content in memory location) == ".", then print (contents of memory location).

    Hope this clears it up. tc

提交回复
热议问题