12
\$\begingroup\$

Your challenge is to write a Chef program that works well as a recipe and also as a program. Its utility as a recipe is strictly required (I don't want a recipe for grapeleaves in chocolate-mustard sauce); its utility as a program is a looser requirement, so that it is enough to print something interesting (the first few integers, for example, or "just another chef", or "just another Chef hacker", or "hello world") or do some helpful calculation (printing the sum of two numbers, for example). Votes should take this into account, and the winner is the program with the most net upvotes after some time.

(Code length is not important here.)

\$\endgroup\$

closed as too broad by Martin Ender, Doorknob Dec 25 '14 at 22:56

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    \$\begingroup\$ I'm not sure it's worth having a tag for it. Tags are to categorise related questions, and it doesn't seem too likely that we'll have more than one question about Chef. \$\endgroup\$ – Peter Taylor Jan 15 '12 at 23:01
6
\$\begingroup\$

I wrote this program for another challenge, but I decided to try and make it a valid answer for this one too:

Shirred Eggs.

This recipe prints the number 2 and, in doing so, yields two delicious
shirred eggs.

Ingredients.
2 eggs

Cooking time: 12 minutes.

Pre-heat oven to 175 degrees Celsius.

Method.
Put eggs into mixing bowl. Pour contents of the mixing bowl into the
baking dish. Shirr the eggs. Bake the eggs until shirred.

Serves 1.

As I mentioned in the other answer, it seems pretty hard to write anything in Chef that involves something more complicated than mixing stuff in a bowl and baking it, and still have it work both as a program and as a recipe.

Edit: Changed the recipe from fried to shirred eggs — thanks to Blazer for the suggestion! The cooking time and temperature should be considered advisory only; I haven't actually tried the recipe yet myself, so I can't vouch for their accuracy.

\$\endgroup\$
  • \$\begingroup\$ Waitaminute: as is, this outputs 1, not 2. ("Fry the eggs until baked" decrements eggs.) No? \$\endgroup\$ – msh210 Feb 6 '12 at 19:05
  • \$\begingroup\$ I tested this using the Acme::Chef interpreter, and it outputs 2. The last two sentences in the "Method" section don't actually affect the output at all (since it's already been moved to the baking dish), they're just there to tell you not to eat the eggs raw. \$\endgroup\$ – Ilmari Karonen Feb 6 '12 at 19:16
  • \$\begingroup\$ Ah, of course: quite right. \$\endgroup\$ – msh210 Feb 6 '12 at 19:19

Not the answer you're looking for? Browse other questions tagged or ask your own question.