Quine: Difference between revisions

From APL Wiki
Jump to navigation Jump to search
mNo edit summary
(Added a new entry)
Line 16: Line 16:
* <source lang=apl inline>,⍨</source> concatenate with itself, resulting in <source lang=text inline>'1⌽,⍨9⍴'''1⌽,⍨9⍴''</source>
* <source lang=apl inline>,⍨</source> concatenate with itself, resulting in <source lang=text inline>'1⌽,⍨9⍴'''1⌽,⍨9⍴''</source>
* <source lang=apl inline>1⌽</source> rotate one character to the left, getting the characters: <source lang=text inline>1⌽,⍨9⍴'''1⌽,⍨9⍴'''</source>
* <source lang=apl inline>1⌽</source> rotate one character to the left, getting the characters: <source lang=text inline>1⌽,⍨9⍴'''1⌽,⍨9⍴'''</source>
== Further Entries ==
In 2022, [[APL Farm]] user oskar31415 shared the following:
<source lang=apl>
      ¯1↓1↓,⍨16⍴15⍴'''¯1↓1↓,⍨16⍴15⍴'
</source>


== External links ==
== External links ==

Revision as of 18:08, 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