Quine
Revision as of 13:01, 13 August 2020 by Andrii Makukha (talk | contribs)
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⍴'''
External links
- ↑ Transcript for 2019-01-06 – APL Orchard.
- ↑ Golf you a quine for great good! – APL (Dyalog Unicode), 18 bytes – Code Golf Stack Exchange.