Cheesecake
Twelve stack commands, every one of them spelled with the words cheese and cake.
Nebular · Turing complete: unknown · ●○○ easy · esolangs.org
Tested with 2 known programs · Test method
Run it
The idea
Nebular made Cheesecake in a few hours. It is a small stack machine where each command is a short run of the words cheese and cake, and the word cheesecake sits between a command and its argument. Numbers are spelled too. A number is the word cake with one e more than its value, so cake is 0, cakee is 1 and printing an H needs a cake with 73 of them, unless you multiply.
The machine
One instruction per line.
| Words | Does |
|---|---|
cheese cheesecake n | Push n |
cake cheese cake cake cheese | Discard, duplicate, swap |
cheese cheese cake cake | Add, subtract |
cheese cheese cheese cheese cheese cake | Multiply, divide |
cheese cake cake cheesecake n | Jump to line n if the top is 0 |
cake cake cake cheese cheese cheese cheese | Print the top as a character or as a number |
cheese cheese cheese cake | Read a character |
The specification leaves the details to its programs. Its Hello world only prints text if printing a character pops it and subtraction takes the top from the one below it. Its truth machine only works if the jump leaves the top where it is. Lines count from 1, which makes every line of the truth machine do work.
Example
Six times seven.
Six times seven.
The truth machine reads a character and takes 48 from it. On 0 the jump goes to line 10, which pushes a 0 to print. On 1 it loops over lines 5 to 9 and prints 1 forever.
The Hello world is 56 lines. It builds each letter from small numbers, keeps a copy with cheese cake to make the next one, and prints Hello, world!.
Patterns it teaches
- Stack machines: one stack and a jump on zero.
- Encoding tricks: numbers written in unary, as the length of a word.
Further
See also
Pseudonatural
Stack-based
Write your own in Run Convert a program from Cheesecake
Implementation
JavaScript interpreter, source and command line
A JavaScript interpreter, used in the browser and on the command line. Id: cheesecake.
Command line
shib run cheesecake program.txt --input '0'The program is long; save it as program.txt first.
shib manual cheesecakeSource
- Module
langs/wiki/ports.js- Interpreter
langs/wiki/cheesecake.js
Docs: Kernel instructions · The .shib format · Command line · Adding a language
Source esolangs.org (CC0) · Edit on esolangs.org