Javascript ES6 (REPL), 52 bytes
var a=a||'';$=_=>a+=`$=${$};$();`.repeat(a?1:2);$();
#Javascript ES6 (REPL), 52 bytes
var a=a||'';$=_=>a+=$=${$};$();
.repeat(a?1:2);$();
InitialInitial working implementation, may be golfable.
y.onclick=_=>z.innerText=eval("var a=a||'';$=_=>a+=`$=${$};$();`.repeat(a?1:2);$();".repeat(x.value))
<input id=x><button id=y>Submit!</button><pre id=z></pre>
Explanation
#Explanation
BasedBased on my usual quine implementation ($=_=>`$=${$};$()`;$()
).
var a||''
coerces a
to an empty string if it isn't defined; otherwise, a
is left as is. a
will store our final result.
Each function call, a
will be checked to see if it is empty/falsy. The first function call will append 2 copies of the quine because a
is empty; subsequent calls will only append 1 copy because a
is no longer empty.
The last function call will output the final value of a
after finishing.