Fuzion Logo
fuzion-lang.dev — The Fuzion Language Portal
JavaScript seems to be disabled. Functionality is limited.

Idiom # 182: Quine program

See programming-idioms.org:

A quine is a program that prints its own source code.

Code

A quine defined as a feature:

The idea in this code is that it contains a list a of strings of all the lines of its source code and then prints this list up to the start of the list contents, then prints the whole list wrapped in quotes and separated by commas, and finally prints the tail of the list, which is the code ending the list declaration and the following code.

A trick used in this code is to define features q and c that returns constant strings containing a double quote "\"" and a comma ",", respectively. Using q and c avoids the need for quotes in the code, which would need special handling to create the correct escape sequences.

A quine can be slightly smaller if it is not wrapped in a feature, but runs directly in the universe and if some redundant whitespace is removed:

last changed: 2024-07-01