I Will Be Sad When This Class Is Over

Nov 20, 2009 02:12

For our 5th project in Intro to Computational Media, we were directed to write a program in an esoteric programming language called Chef (http://www.dangermouse.net/esoteric/chef.html). Programs in Chef look like recipes. Here's mine:

--
RIAA Waffles.

The perfect breakfast before being fined for illegally downloading music. These waffles feature an orange flavor, which helps to fight off scurry among pirates. Adaptation of http://culinaryarts.about.com/od/griddledspecialties/r/basicwaffles.htm

Ingredients.
3 level cups all-purpose flour
4 level teaspoons baking powder
2 level teaspoons salt
2 heaped tablespoons granulated sugar
5 pinches brown sugar
7 eggs
3 cups whole milk
4 tablespoons vegetable oil
1 teaspoon orange zest
1 teaspoon pure vanilla extract
2 tablespoons fresh-squeezed orange juice
2 dashes nutmeg

Method.
Put all-purpose flour into the mixing bowl.
Combine baking powder into the mixing bowl.
Combine salt into the mixing bowl.
Combine granulated sugar into the mixing bowl.
Fold orange zest into the mixing bowl.
Whisk the eggs.
Put orange zest into the mixing bowl.
Whisk the eggs until whisked.
Fold eggs into the mixing bowl.
Put eggs into the mixing bowl.
Add fresh-squeezed orange juice into the mixing bowl.
Stir fresh-squeezed orange juice into the mixing bowl.
Add brown sugar into the mixing bowl.
Stir nutmeg into the mixing bowl.
Divide vegetable oil into the mixing bowl.
Combine whole milk into the mixing bowl.
Liquify contents of the mixing bowl.
Pour contents of the mixing bowl into the baking dish.

Serves 18000.

--

The way Chef works is by assigning numbers to variables. "5 level cups of all-purpose flour" assigns the number 5 to the variable "all-purpose flour". "level cups" tells Chef that this is a Dry ingredient instead of a Wet one. Wet ingredients are outputted as Unicode characters... dry ones are numerical. Hence, why I liquify(sic) the entire mixture before I prepare it for output (pouring the mixing bowl, which is the stack of data, into the baking dish). Anyway, I found this a lot of fun, contrary to most of my classmates, who didn't see the value in doing something like this.

Here's what it does, line by line:

Method.
Put all-purpose flour into the mixing bowl.
Puts 3 on top of the stack.
Combine baking powder into the mixing bowl.
Multiplies 4 by the number on top of the stack, which is now 12.
Combine salt into the mixing bowl.
Multiplies 2 by the number on top of the stack, which is now 24.
Combine granulated sugar into the mixing bowl.
Multiplies 2 by the number on top of the stack, which is now 48.
Fold orange zest into the mixing bowl.
Copies the number on top of the stack to the variable "orange zest", making "orange zest" 48.
Whisk the eggs.
Starts a program loop.
Put orange zest into the mixing bowl.
Puts 48 in the stack every time the loop is executed... which is however many eggs we have minus 1 (7). So now we have:
STACK: 48 48 48 48 48 48
Whisk the eggs until whisked.
End the loop.
Fold eggs into the mixing bowl.
Copies 48 to the variable eggs.
Put eggs into the mixing bowl.
Puts another 48 on the stack.
Add fresh-squeezed orange juice into the mixing bowl.
Adds 2 to the top number of the stack
STACK: 50 48 48 48 48 48 48
Stir fresh-squeezed orange juice into the mixing bowl.
Moves the top number on the stack down however many layers as the variable passed... in this case 2.
STACK: 48 48 50 48 48 48 48
Add brown sugar into the mixing bowl.
STACK: 53 48 50 48 48 48 48
Stir nutmeg into the mixing bowl.
STACK: 48 50 53 48 48 48 48
Divide vegetable oil into the mixing bowl.
My most shady recipe command, but I had to reduce the first number somehow. Divide obviously divides by the number.
STACK: 12 50 53 48 48 48 48
Combine whole milk into the mixing bowl.
Multiplication on the top number again.
STACK: 36 50 53 48 48 48 48
Liquify contents of the mixing bowl.
Turns these all into Unicode characters
STACK: $ 2 5 0 0 0 0
Pour contents of the mixing bowl into the baking dish.
Prints the final output, which is:

$250000 (the maximum fine for pirating one single mp3)

I was pretty pleased with how this turned out, and I think you might actually be able to cook this (which was a requirement if one wanted to get an A on the project). I didn't square numbers or perform a Fibonacci sequence like my classmates, but I also didn't tear my hair out writing this program, either!
Previous post Next post
Up