Lesson 10
Quotations in Underload
Underload has no numbers at all; its stack holds texts. (text) pushes a text, S prints the top one, : duplicates, ! drops, ~ swaps and * joins the top two.
The lesson
In the Underload dictionary, the parentheses are the kernel's own quotation brackets [ and ], so a quoted text is a kernel list.
Underload has its own page, and Run opens this example in the editor.
Example
Output
Exercise 1
Start with (a)(b) and print ab.
Run tries your program on the input below. Check runs it on every test.
| Input | Expected output |
|---|---|
(empty) | ab |
Output
A hint
S prints the top text, which is b. Swap first.
One answer
Answer: Start with (a)(b) and print ab.
Expected output
ab
| Input | Expected output |
|---|---|
(empty) | ab |
Output
Exercise 2
Print hahaha with only one (ha) in your program.
Run tries your program on the input below. Check runs it on every test.
| Input | Expected output |
|---|---|
(empty) | hahaha |
Output
A hint
Three copies, then two joins.
One answer
Answer: Print hahaha with only one (ha) in your program.
Expected output
hahaha
| Input | Expected output |
|---|---|
(empty) | hahaha |
Output