Acme-Chef

Implementation of programming language Chef

Interpreter and compiler created by Steffen Müller. Is written in Perl and licensed under Artistic and GNU GPL. Note that it supports the outdated spelling of instruction Liquefy — Liquify.

Examples:

Hello, World!:

Example for versions Acme-Chef-1.01

Each ingredient holds ASCII-code of one message character; for convenience their names start with the letters they hold. The codes are placed in the bowl in reverse-printing order. Then Liquify (old spelling of the command is used to make the program run in the interpreter) makes all elements of the bowl liquid (i.e. states that they should be printed as characters). Finally, the contents of the bowl is moved to the baking dish, and Serves 1 prints its contents.

Lobsters with Fruit and Nuts.

This recipe prints "Hello, World!" in a most delicious way.

Ingredients.
72 g hazelnuts
101 eggs
108 g lobsters
111 ml orange juice
44 g cashews
32 g sugar
87 ml water
114 g rice
100 g durian
33 passion fruit
10 ml lemon juice

Method.
Put lemon juice into the mixing bowl.
Put passion fruit into the mixing bowl.
Put durian into the mixing bowl.
Put lobsters into the mixing bowl.
Put rice into the mixing bowl.
Put orange juice  into the mixing bowl.
Put water into the mixing bowl.
Put sugar into the mixing bowl.
Put cashews into the mixing bowl.
Put orange juice into the mixing bowl.
Put lobsters into the mixing bowl.
Put lobsters into the mixing bowl.
Put eggs into the mixing bowl.
Put hazelnuts into the mixing bowl.
Liquify contents of the mixing bowl.
Pour contents of the mixing bowl into the baking dish.

Serves 1.

Factorial:

Example for versions Acme-Chef-1.01

This example uses iterative factorial definition. Ingredients measured in ml are liquid (characters), the ones measured in g are dry (numbers).

The program consists of two loops. First one, chop ... until choped, calculates the factorials in ascending order and pushes elements to be printed in the first bowl, characters and numbers alike. Smaller values which should be printed first end up at the bottom of the stack. This is cured by using the second bowl and the second loop, mash ... until mashed, which moves elements from the first bowl to the second one, so that they get to be printed in correct order.

Unfortunately, the current version of the interpreter processes liquid ingredients in a wrong way — neither liquid units of measurement, nor the command luquify modify their state, so they are printed as dry. Thus, the program output looks as follows:

0 33 32 61 32 1 10 1 33 32 61 32 1 10 2 33 32 61 32 2 10 3 33 32 61 32 6 10 4 33 32 61 32 24 10 5 33 32 61 32 120 10 6 33 32 61 32 720 10 7 33 32 61 32 5040 10 8 33 32 61 32 40320 10 9 33 32 61 32 362880 10 10 33 32 61 32 3628800 10 11 33 32 61 32 39916800 10 12 33 32 61 32 479001600 10 13 33 32 61 32 6227020800 10 14 33 32 61 32 87178291200 10 15 33 32 61 32 1307674368000 10 16 33 32 61 32 20922789888000 10

Factorial as a Piece of Cake.

This recipe calculates and prints factorials of first integers.

Ingredients.
33 ml exclamation
32 ml space
61 ml equal
10 ml newline
0 g n
1 g f
1 g one
17 g iterator
119 g second iterator

Method.
Liquify exclamation.
Liquify space.
Liquify equal.
Liquify newline.
Chop iterator.
Put n into 1st mixing bowl.
Put exclamation into 1st mixing bowl.
Put space into 1st mixing bowl.
Put equal into 1st mixing bowl.
Put space into 1st mixing bowl.
Put f into 1st mixing bowl.
Put newline into 1st mixing bowl.
Put n into 1st mixing bowl.
Add one into 1st mixing bowl.
Fold n into 1st mixing bowl.
Put f into 1st mixing bowl.
Combine n into 1st mixing bowl.
Fold f into 1st mixing bowl.
Chop iterator until choped.
Mash second iterator.
Fold n into 1st mixing bowl.
Put n into 2nd mixing bowl.
Mash second iterator until mashed.
Pour contents of 2nd mixing bowl into the baking dish.

Serves 1.

Fibonacci numbers:

Example for versions Acme-Chef-1.01

This example uses iterative calculation of Fibonacci numbers. Last and one-before-last calculated numbers are stored in ingredients fib1 and fib2, respectively. In one iteration of loop chop ... until choped the next number is calculated, and the previous one is written to the stack for being printed later. Second loop mash ... until mashed pours the values from first bowl into second one, so that they can be printed in correct (increasing) order.

This version of the interpreter doesn’t allow to hold liquid and dry ingredients on one stack, and thus disallows printing both numbers and characters in one message. This punctuation has been dropped from the output; the result looks as follows:

1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987

Fibonacci numbers.

This recipe calculates and prints first Fibonacci numbers.

Ingredients.
0 g fib1
1 g fib2
16 g iterator
16 g second iterator

Method.
Chop iterator.
Put fib2 into 1st mixing bowl.
Put fib2 into 1st mixing bowl.
Add fib1 into 1st mixing bowl.
Fold fib2 into 1st mixing bowl.
Fold fib1 into 1st mixing bowl.
Put fib1 into 1st mixing bowl.
Chop iterator until choped.
Mash second iterator.
Fold fib1 into 1st mixing bowl.
Put fib1 into 2nd mixing bowl.
Mash second iterator until mashed.
Pour contents of 2nd mixing bowl into the baking dish.

Serves 1.