Lesson 12
The Underload quine
A quine is a program that prints its own source. In Underload it is short, because a turns a text back into the source that pushes it.
The lesson
The example shows the trick in pieces. It pushes (hello) and duplicates it, a wraps one copy, and two prints follow. In the quine the pushed text is (:aSS) itself.
Underload has its own page, and Run opens this example in the editor. Quines collects more, in other languages.
Example
Output
Exercise 1
Write a program that prints exactly its own source.
Run tries your program on the input below. Check runs it on every test.
| Input | Expected output |
|---|---|
(empty) | its own program text |
Output
A hint
Put the commands :aSS inside the parentheses too.
One answer
Answer: Write a program that prints exactly its own source.
Expected output
(:aSS):aSS
| Input | Expected output |
|---|---|
(empty) | its own program text |
Output