Search

jeudi 2 mars 2017

Quine: build data (3)

Context

We now have an almost fully-function quine. We just have to convert to code into data.
And because of my monomania, this part itself will be done using BF :)
Initial state

  • Memory: empty
  • Cursor: first cell
  • Input: some code to convert into data

Process

  • First, generate + and > symbols
  • Then, for each char read
    • Print + as many times as the char value
    • Then print >

Code - try it

generate PLUS and GT
++++++[->++++++++++>+++++++<<]>++>+
read cell
>,[
  print PLUS as many times as needed
  [-<.>]
  print GT
  <<.
  loop
  >>,
]

Final state

  • Memory: 0 62 43 0 0 0 0
  • Cursor: fourth cell
  • Input: empty
  • Output: our input code converted into data format


Aucun commentaire:

Enregistrer un commentaire