Generate Programs in Increasing size
CJam, 10 bytes
{"_~"+_}_~
Test it here.
Explanation
{"_~" e# Generalised quine framework, leaves the block and the string "_~"
e# on the stack.
+ e# Prepend the block to the string.
_ e# Duplicate the resulting array.
}_~
JavaScript, 62 61 37 bytes
Thanks to @Doᴡɴɢᴏᴀᴛ for the help!
Original [37 bytes]:
f=_=>'f='+'_'.repeat((10+f).length)+f
Child [74 bytes]:
f=______________________________________=>'f='+'_'.repeat((10+f).length)+f
Grandchild [148 bytes]:
f=________________________________________________________________________________________________________________=>'f='+'_'.repeat((10+f).length)+f
Alternate (with printing to console, and as a full program):
Original [61 bytes]:
f=_=>console.log(`f=${'_'.repeat((0+f).length+5)+f};f()`);f()
Child [122 bytes]:
f=______________________________________________________________=>console.log(`f=${'_'.repeat((0+f).length+5)+f};f()`);f()
Grandchild [244 bytes]:
f=________________________________________________________________________________________________________________________________________________________________________________________=>console.log(`f=${'_'.repeat((0+f).length+5)+f};f()`);f()
How it works!
1. f=_=>
Define function f as console.log(...)
2. ;f()
Run function f.
3. (in function f)
console.log(...)
Print the following:f=
literal text "f="${'_'.repeat((0+f).length+5)
"_" repeated for the length of f, altered to account for characters not included in the stringification of f+f}
The stringification of function f;f()
literal text ";f()"
Notes
console.log
is necessary instead ofalert
becausealert
doesn't seem to play well with really long strings (at least on my machine/browser configuration)- The
_
's are inserted into the name of the (unused) parameter of function f, to ensure that they are included in the stringification of f. - Main improvement (aside from getting rid of the
console.log
) of the first solution over the second: adding10
to the function instead of0
to cast it to string makes it one byte longer, eliminating the need to add 1 to the length afterwards, saving a byte.
Minkolang 0.15, 19 14 bytes
"66*2-rIDdr$O.
Original, child, grandchild.
Explanation
"66*2- $O. Standard quine formulation
r Reverse stack
I Push length of stack
D Pop n and duplicate top of stack n times
d Duplicate top of stack
r Reverse stack
What the bit in between r
s does is duplicate the ending period enough times to fulfill the doubling criterion. .
is the "stop program" character, so the many periods at the end do nothing except be there.