# Russian Nesting Quine

A Russian nesting doll, more commonly known as a Matryoshka doll, is a doll which contains a smaller version of itself, which then contains another smaller version of itself, which contains a smaller version of itself, which contains a smaller version of itself, which contains a smaller version of itself... - until finally, the last one is empty. An example:

Today your goal is to emulate this Russian tradition by writing a program or function that, when it contains itself N times, will print itself containing N-1 copies of itself times.

For example, the doll program abcd will have the N=3 program abababcdcdcd, which will print the N=2 program ababcdcd, which prints the original N=1 program abcd, which finally prints N=0, which is empty. This should theoretically work for any reasonable value of N.

Rules:

• Here is a TIO program to help generate doll programs based on your program
• Standard Quine Rules apply
• Standard Loopholes apply
• 'Contains' means directly in the center of the previous version, so your solution must have a positive even number of bytes. A program of length 10 will have a copy of the original inserted after the fifth byte, then another after the tenth byte etc.
• A single trailing whitespace is allowed in the output
• As this is , your goal is to make your N=1 program as short as possible.
• An explanation of your code would be appreciated
• Sandbox post (deleted) – Jo King Feb 2 '18 at 9:12
• For what N is the code size measured? – flawr Feb 2 '18 at 9:52
• @flawr N=1..... – Jo King Feb 2 '18 at 10:06
• Related: One More Program and I'm Out! – Kevin Cruijssen Feb 2 '18 at 11:15
• Is that animation really necessary?! – Shaggy Feb 2 '18 at 11:28

N=1: Try it online.

 ()S


N=2: Try it online.

 ( ()S)S


N=3: Try it online.

 ( ( ()S)S)S


Explanation:

Self-explanatory, but I add it anyway.

• (...)S prints anything between the parenthesis to STDOUT
• The space before it is a no-op to make the byte-count even and comply to the rules of the challenge.

# JavaScript, 36 32 bytes

Takes advantage of the fact that Function.prototype.toString() takes no arguments and will therefore ignore any that are passed to it.

Partly inspired by user202729's solution.

f=_=>f.toString( ).slice(14,-16)


## Try it

o.innerHTML=["<span>Five</span>",(f=_=>f.toString(f=_=>f.toString(f=_=>f.toString(f=_=>f.toString(f=_=>f.toString( ).slice(14,-16) ).slice(14,-16) ).slice(14,-16) ).slice(14,-16) ).slice(14,-16))(),"<span>Four</span>",(f=_=>f.toString(f=_=>f.toString(f=_=>f.toString(f=_=>f.toString( ).slice(14,-16) ).slice(14,-16) ).slice(14,-16) ).slice(14,-16))(),"<span>Three</span>",(f=_=>f.toString(f=_=>f.toString(f=_=>f.toString( ).slice(14,-16) ).slice(14,-16) ).slice(14,-16))(),"<span>Two</span>",(f=_=>f.toString(f=_=>f.toString( ).slice(14,-16) ).slice(14,-16))(),"<span>One</span>",(f=_=>f.toString( ).slice(14,-16))(),"<span>Thunderbirds Are Go!</span>"].join\n
span{font-weight:bold;font-size:16px;line-height:1.5em;text-transform:uppercase;}span:last-child{font-size:8px;}
<pre id=o></pre>

# JavaScript (Node.js), 46 bytes

Full program. So console.log is necessary.

Use an idea from this answer to save some bytes.

l=console.log;   g=_=>{};l((''+g).slice(4,-1))


My approach is similar to that used in Kevin Cruijssen's answer, find a nestable structure (a function in this case).

# Jelly, 16 bytes

Ṿḣ-9Ḋð}“““““““““


Try it online!

Doubled: Try it online!

Tripled: Try it online!

Jelly doesn't have any nestable structure, but its string literals are auto-terminated.


Ṿ        UneṾal. (to string)
ḣ-9     Take the ḣead, ends at the -9'th character.
Ḋ    Ḋequeue, remove the first character.

ð             Terminate the first chain, start a new one.
“““““““““   String literal.
the the corresponding rules. This way a link can take data
to the right of it.


Will try different approaches to see if they can be shorter.

# DipDup, 2 bytes

[]


It pushes the list onto the stack, and prints it without the outmost brackets.

N = 1: Try it online!

N = 2: Try it online!

N = 3: Try it online!

# dc, 4 bytes

 []p


Similar to some other answers, since strings in dc have start ([) and end (]) delimiters (that is, " doesn't perform both duties, etc.), they're nestable without any real effort. p to print.

N=1: Try it online!

N=2: Try it nested!

N=3: Try it nesteder!

# Tcl, 12 bytes

puts {}


Try it online!

It's just another language that also has this.