Quine: Difference between revisions

From APL Wiki
Jump to navigation Jump to search
(Added a new entry)
Line 19: Line 19:
== Further Entries ==
== Further Entries ==


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⍴'
       ¯1↓1↓,⍨16⍴15⍴'''¯1↓1↓,⍨16⍴15⍴'

Revision as of 19:23, 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":

      12211'''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:

      ¯11↓,1615'''¯1↓1↓,⍨16⍴15⍴'

External links