Write a mutating, replicating program

Jelly, 4 bytes

⁾ṘȮṘ

Try it online!

(Equivalent to the 5-byte: “ṘȮ”Ṙ)

Exponentially spawns:

“ṘȮ”ṘȮ
“ṘȮ”ṘȮṘȮ
“ṘȮ”ṘȮ“ṘȮ”ṘȮṘȮ
“ṘȮ”ṘȮṘȮ“ṘȮ”ṘȮ“ṘȮ”ṘȮṘȮ
“ṘȮ”ṘȮ“ṘȮ”ṘȮṘȮ“ṘȮ”ṘȮṘȮ“ṘȮ”ṘȮ“ṘȮ”ṘȮṘȮ

Since is a monadic atom which prints a Jelly representation of its input and then yields it's input, and Ȯ is a monadic atom which prints its input and yields it's input (neither printing any newlines), while “...” defines a list of characters. So each “ṘȮ”Ṙ prints “ṘȮ” and yields to the following Ȯ which prints ṘȮ and yields... a trailing Ȯ finally yields for the programs return value, which is implicitly printed, so the pattern will continue until resources no longer suffice.


SOGL, 9 bytes

:+q$o”q$o

Explanation:

:+q$o”     push that string
      q    output it in a new line without popping
       $   push "”"
        o  output that
           implicitly output the original string (in a new line)

The iterations go as (one per line)

:+q$oӦ:+q$o
:+q$o:+q$oӦ:+q$o:+q$o
:+q$o:+q$o:+q$o:+q$oӦ:+q$o:+q$o:+q$o:+q$o:+q$o:+q$o:+q$o:+q$oӦ:+q$o:+q$o:+q$o:+q$o:+q$o:+q$o:+q$o:+q$o

and the next one is 31424 characters long.

The first iteration is

:+q$o”        push that string
      ¶       no-op
       :+     add the string to itself
         q    output it in a newline without popping
          $o  append "”"

and the next:

:+q$o:+q$o”             push that string
           ¶            no-op
            :+          add the string to itself
              q         output it in a newline without popping
               $o       append "”"
                 :+q$o  the same

This should never break from what I can see (well except hitting javas string length limit or something), because only the last string is used and the rest of the code is just multiply, output.

note: newlines and are completely interchangeable in SOGL.


Pyth, 11 bytes

jN*2]"jN*4[

Try it

Try it online

Gets exponentially longer. Based on this Pyth Quine.

first 4 iterations

jN*2]"jN*4[
jN*4["jN*4[
jN*4["jN*4["jN*4["jN*4[
jN*4["jN*4["jN*4["jN*4["jN*4["jN*4["jN*4["jN*4["jN*4["jN*4["jN*4["jN*4["jN*4["jN*4["jN*4["jN*4["jN*4["jN*4["jN*4["jN*4[

Explanation

jN*4]"jN*4[
     "jN*4[                 # The String "jN*4["
    ]                       # Make it into a list with one element
  *4                        # Quadruple that list
jN                          # join on quote (N='"')

jN*4["jN*4["jN*4["jN*4[     
                 "jN*4[     # The string "jN*4["
                [           # List with the string: ["jN*4["]
              *4            # Quadruple that list
            jN              # Join on quote
     "jN*4["                # The string "jN*4["
    [                       # Put both strings into a list
  *4                        # Quadruple that list
jN                          # join on quote (N='"')

(I could probably prove this rigoriosly using induction, but I'm not in the mood for that.) This should (theoretically always work because) it's just even multiples of jN*4[". Every second occurence of that sequence of characters is interpreted as a string because of the " of the previous one. The [ of the previous one then puts that string into a list together with what the next one produces. Then that list is repeated four times and joined to string with ".

Tags:

Code Golf