Vitsy, 10 27 Bytes
'rddd++&"rdd8++a[v}v1-D);].
Wenn :
erlaubt, könnte ich dies auf 11 Bytes verkürzen. :(
Erläuterung:
'rddd++&"rdd8++a[v}v1-D);].
' Capture all instructions as a string until encountering
' again, looping if necessary.
r Reverse the current stack (output is top-down).
ddd++ Push char literal ' to the stack.
& Push a new stack to the stack stack.
" Same as ', but " specific.
r Reverse the current stack.
dd8++ Push char literal " to the stack.
a Push 10 to the stack.
[ ] Loop forever.
v Capture the top value as a variable.
} Take the bottom item of the stack and put it on the top.
v Dump the variable to the stack.
1- Subtract 1.
D Duplicate the top item.
); Pop n; if n is 0, exit the loop.
a[v v1-D);] This is a makeshift for loop with 10 iterations.
. Pop the top stack as n, and the second stack as o.
Write a file called "n" with the contents of "o".
Die beiden Stapel sind am Ende identisch. In einigen Java-Versionen kann dies FileNotFoundException
aufgrund unterschiedlicher Implementierungen der FileInputStream
Klasse zu einem Fehler führen.
Vorherige Antwort vor dem Bearbeiten:
&'rddd++}.
Erläuterung:
& Push a new stack to the stack stack.
'rddd++ Modified standard quine.
} Move the ' to the right place.
. Pop the top stack as n, and the second stack as o. Write a file called
"n" with the contents of "o". (Quine name, no content)
Da ich genauso gut könnte, ist hier ein Diagramm der Schritte, die innerhalb der Stapel auftreten (jeder Stapel wird durch dargestellt []
):
Initial state: [[]]
& [[], []]
Push a new stack to the stack stack.
' [[], ["r", "d", "d", "d", "+", "+", "}", ".", "&"]]
This stack state occurs because ' will loop around the line
until finding the next '.
r [[], ["&", ".", "}", "+", "+", "d", "d", "d", "r"]]
Reverses the top (last) stack.
ddd [[], ["&", ".", "}", "+", "+", "d", "d", "d", "r", 13, 13, 13]
Push thirteen thrice.
++ [[], ["&", ".", "}", "+", "+", "d", "d", "d", "r", "'"]
Because char ' is 39 = 13 + 13 + 13.
} [[], [".", "}", "+", "+", "d", "d", "d", "r", "'", "&"]]
Takes the bottom item, then puts it on the top.
. []
Writes a file with content from the second-to-top stack and the
name as the concatenation of all elements in the top stack,
with top member priority (backwards from my representation).
Ich bin mir eigentlich nicht sicher, wie das richtig funktioniert. winzige Änderungen führen dazu, dass dies unterbrochen wird. Zum Beispiel sollte das Platzieren &
an verschiedenen anderen Orten genauso gut funktionieren, aber es verursacht ClassCastException
s, IOException
s und ArrayOutOfBoundsException
s, je nachdem, wo Sie es platzieren. Möglicherweise muss ich einige Fehlerbehebungen vornehmen.