Skip to main content
edited body
Source Link
a06e
  • 11.5k
  • 4
  • 49
  • 112

A quine is a computer program which takes no input and produces a copy of its own source code as its only output. There are many trivial quines in Mathematica:

In[1]:= "Hello world"
Out[1]= "Hello world"

In[2]:= 3.14
Out[2]= 3.14

In[3]:= f[x]
Out[3]= f[x]

where f and x are undefined symbols; and some more

In[4]:= Hold[N[\[Pi]]]
Out[4]= Hold[N[\[Pi]]]

These are all trivial. I was thinking that perhaps a more interesting challenge for Mathematica was a multiquine. This is a program A that outputs another program B, distinct from A, such that when B is exectuedexecuted, the output is A. Multiple levels of depth are also allowed: Thus one might have a program that when executed outputs a distinct program that when executed outputs another program distinct from the first two ... that when executed outputs the original program.

There are also multiquines that output a distinct program in a different language, such that when this program is executed, the output is the original program.

QUESTION (Though more of a challenge): Can you come up with a multiquine for Mathematica?

A quine is a computer program which takes no input and produces a copy of its own source code as its only output. There are many trivial quines in Mathematica:

In[1]:= "Hello world"
Out[1]= "Hello world"

In[2]:= 3.14
Out[2]= 3.14

In[3]:= f[x]
Out[3]= f[x]

where f and x are undefined symbols; and some more

In[4]:= Hold[N[\[Pi]]]
Out[4]= Hold[N[\[Pi]]]

These are all trivial. I was thinking that perhaps a more interesting challenge for Mathematica was a multiquine. This is a program A that outputs another program B, distinct from A, such that when B is exectued, the output is A. Multiple levels of depth are also allowed: Thus one might have a program that when executed outputs a distinct program that when executed outputs another program distinct from the first two ... that when executed outputs the original program.

There are also multiquines that output a distinct program in a different language, such that when this program is executed, the output is the original program.

QUESTION (Though more of a challenge): Can you come up with a multiquine for Mathematica?

A quine is a computer program which takes no input and produces a copy of its own source code as its only output. There are many trivial quines in Mathematica:

In[1]:= "Hello world"
Out[1]= "Hello world"

In[2]:= 3.14
Out[2]= 3.14

In[3]:= f[x]
Out[3]= f[x]

where f and x are undefined symbols; and some more

In[4]:= Hold[N[\[Pi]]]
Out[4]= Hold[N[\[Pi]]]

These are all trivial. I was thinking that perhaps a more interesting challenge for Mathematica was a multiquine. This is a program A that outputs another program B, distinct from A, such that when B is executed, the output is A. Multiple levels of depth are also allowed: Thus one might have a program that when executed outputs a distinct program that when executed outputs another program distinct from the first two ... that when executed outputs the original program.

There are also multiquines that output a distinct program in a different language, such that when this program is executed, the output is the original program.

QUESTION (Though more of a challenge): Can you come up with a multiquine for Mathematica?

Source Link
a06e
  • 11.5k
  • 4
  • 49
  • 112

Mathematica quine

A quine is a computer program which takes no input and produces a copy of its own source code as its only output. There are many trivial quines in Mathematica:

In[1]:= "Hello world"
Out[1]= "Hello world"

In[2]:= 3.14
Out[2]= 3.14

In[3]:= f[x]
Out[3]= f[x]

where f and x are undefined symbols; and some more

In[4]:= Hold[N[\[Pi]]]
Out[4]= Hold[N[\[Pi]]]

These are all trivial. I was thinking that perhaps a more interesting challenge for Mathematica was a multiquine. This is a program A that outputs another program B, distinct from A, such that when B is exectued, the output is A. Multiple levels of depth are also allowed: Thus one might have a program that when executed outputs a distinct program that when executed outputs another program distinct from the first two ... that when executed outputs the original program.

There are also multiquines that output a distinct program in a different language, such that when this program is executed, the output is the original program.

QUESTION (Though more of a challenge): Can you come up with a multiquine for Mathematica?