Quine: Difference between revisions

Jump to navigation Jump to search
1,421 bytes added ,  23:02, 17 May 2022
add explanations for the quine by OsKaR31415
(add explanations for the quine by OsKaR31415)
Line 23: Line 23:
       '{∊⍵⍺⍵⍺,4/⍵}'{∊⍵⍺⍵⍺,4/⍵}''''
       '{∊⍵⍺⍵⍺,4/⍵}'{∊⍵⍺⍵⍺,4/⍵}''''
</source>
</source>
In this code, the main function is <source lang=apl inline>{∊⍵⍺⍵⍺,4/⍵}</source>. In this function, the right argument <source lang=apl inline>⍵</source> is the literal <source lang=apl inline>'</source>, and the left argument <source lang=apl inline>⍺</source> is the string containing the representation of the function : <source lang=apl inline>'{∊⍵⍺⍵⍺,4/⍵}'</source>.
The idea behind this quine is that the only thing you need to have a string containing the original code is to reproduce this structure : <source lang=text inline>[quote] [function] [quote] [function] [quote] [quote] [quote] [quote]</source>. So this is precisely what the function does : given the representation of a function <source lang=apl inline>⍵</source> (itself in this case), and a string <source lang=apl inline>⍺</source>(the quote here), it reproduce the structure `⍵ ⍺ ⍵ ⍺ ⍵ ⍵ ⍵ ⍵`. Another quine is <source lang=apl inline>'{∊⍵ ⍺ ⍵ ⍺ ⍵ ⍵ ⍵ ⍵}'{∊⍵ ⍺ ⍵ ⍺ ⍵ ⍵ ⍵ ⍵}''''</source>, and the only thing to notice on this one is the use of <source lang=apl inline>∊</source> so the result is not a nested array of strings, but a flat string.
The quite proposed here is very similar, it only replaces the 4 occurences of <source lang=apl inline>⍵</source> by <source lang=apl inline>4/⍵</source> and deletes the useless spaces for the purpose of golfing.


== External links ==
== External links ==
7

edits

Navigation menu