Quine: Difference between revisions

From APL Wiki
Jump to navigation Jump to search
Line 21: Line 21:
In 2022, [[APL Farm]] user OsKaR31415 shared the following:
In 2022, [[APL Farm]] user OsKaR31415 shared the following:
<source lang=apl>
<source lang=apl>
       ¯1↓1↓,⍨16⍴15⍴'''¯1↓1↓,⍨16⍴15⍴'
       '{∊⍵⍺⍵⍺,4/⍵}'{∊⍵⍺⍵⍺,4/⍵}''''
</source>
</source>



Revision as of 19:59, 17 May 2022

A quine is a program which takes no input and produces a copy of its own source code as its only output.

In APL, a quine is listed in the FinnAPL idiom library as "an expression giving itself":

      1⌽22⍴11⍴'''1⌽22⍴11⍴'''

In 2019, Nick Nikolov proposed to shorten it using the commute operator:[1]

      1⌽,⍨9⍴'''1⌽,⍨9⍴'''

Explanation:[2]

  • '''1⌽,⍨9⍴''' the characters '1⌽,⍨9⍴'
  • 9⍴ reshape to shape 9, resulting in '1⌽,⍨9⍴''
  • ,⍨ concatenate with itself, resulting in '1⌽,⍨9⍴'''1⌽,⍨9⍴''
  • 1⌽ rotate one character to the left, getting the characters: 1⌽,⍨9⍴'''1⌽,⍨9⍴'''

Further Entries

In 2022, APL Farm user OsKaR31415 shared the following:

      '{∊⍵⍺⍵⍺,4/⍵}'{∊⍵⍺⍵⍺,4/⍵}''''

External links