Quine: Difference between revisions
Jump to navigation
Jump to search
(I think it's nice to mention quines in this wiki; similar to: https://code.jsoftware.com/wiki/Puzzles/Quine) |
mNo edit summary |
||
Line 7: | Line 7: | ||
In 2019, [[Nick Nikolov]] proposed to shorten it using the [[commute]] operator:<ref>[https://chat.stackexchange.com/transcript/message/48380903#48380903 Transcript for 2019-01-06] – [[APL Orchard]].</ref> | In 2019, [[Nick Nikolov]] proposed to shorten it using the [[commute]] operator:<ref>[https://chat.stackexchange.com/transcript/message/48380903#48380903 Transcript for 2019-01-06] – [[APL Orchard]].</ref> | ||
<source lang= | <source lang=apl> | ||
1⌽,⍨9⍴'''1⌽,⍨9⍴''' | 1⌽,⍨9⍴'''1⌽,⍨9⍴''' | ||
</source> | </source> | ||
Explanation:<ref>[https://codegolf.stackexchange.com/a/178459/87954 Golf you a quine for great good! – APL (Dyalog Unicode), 18 bytes] – Code Golf Stack Exchange.</ref> | Explanation:<ref>[https://codegolf.stackexchange.com/a/178459/87954 Golf you a quine for great good! – APL (Dyalog Unicode), 18 bytes] – Code Golf Stack Exchange.</ref> | ||
* <source lang=apl inline>'''1⌽,⍨9⍴'''</source> the characters <source lang= | * <source lang=apl inline>'''1⌽,⍨9⍴'''</source> the characters <source lang=text inline>'1⌽,⍨9⍴'</source> | ||
* <source lang=apl inline>9⍴</source> reshape to shape 9, resulting in <source lang= | * <source lang=apl inline>9⍴</source> reshape to shape 9, resulting in <source lang=text inline>'1⌽,⍨9⍴''</source> | ||
* <source lang=apl inline>,⍨</source> concatenate with itself, resulting in <source lang= | * <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= | * <source lang=apl inline>1⌽</source> rotate one character to the left, getting the characters: <source lang=text inline>1⌽,⍨9⍴'''1⌽,⍨9⍴'''</source> | ||
== External links == | == External links == |
Revision as of 13:01, 13 August 2020
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.