Context
We already implemented a quine, and also what we called a double-quine, though it's definitely not an official name.Actually, double-quine may make people think it's a multiquine of 2 languages, which is not the case.
Let's first define what a multiquine is, and then try to implement one.
Considering a set S of N Turing-complete programming languages, a multiquine is a program, written in a language from S, that:
- can be run without argument. It then prints its own source code, like a normal quine
- can be run with an argument (that can have, in theory, N-1 different values). It then prints another program in a different language from S, that have the same 2 properties we are describing.
In other words, considering programming languages A, B and C, I have 3 programs Pa, Pb, Pc written in A, B and C
- When Pa() is executed, it prints Pa's source code.
- When Pa(arg1) is executed, it prints Pb's source code.
- When Pa(arg2) is executed, it prints Pc's source code.
- When Pb() is executed, it prints Pb's source code.
- When Pb(arg3) is executed, it prints Pa's source code.
- When Pb(arg4) is executed, it prints Pc's source code.
- When Pc() is executed, it prints Pb's source code.
- When Pc(arg5) is executed, it prints Pa's source code.
- When Pc(arg6) is executed, it prints Pb's source code.
arg1 may be equal to arg6, arg2 to arg4 and arg4 to arg5, though it's not a mandatory condition.
In the following articles, we'll implement a multiquine for the 3 languages BrainFuck (of course), C# (I don't like Java...) and JavaScript (yes, it's a language)
Aucun commentaire:
Enregistrer un commentaire