Is it possible to create a quine in every turing-complete language?

后端 未结 4 898
清歌不尽
清歌不尽 2020-12-24 12:31

I just wanted to know if it is 100% possible, if my language is turing-complete, to write a program in it that prints itself out (of course not using a file reading function

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-24 12:33

    I ran into this issue a couple of months ago.

    While writing a quine doesn't necessarily prove that a language is Turing Complete, it is a strong suggestion ;) As far as Turing Completeness goes, if you can (like you said) provide a valid translation from your language to another Turing-Complete language, then your language is Turing Complete.

    That being said, any language that is Turing Complete that can output a string should be able to generate a quine. Also, from Wikipedia:

    A quine is a fixed point of an execution environment, when the execution environment is viewed as a function. Quines are possible in any programming language that has the ability to output any computable string, as a direct consequence of Kleene's recursion theorem. For amusement, programmers sometimes attempt to develop the shortest possible quine in any given programming language.

提交回复
热议问题