Those who found themselves confused by my programming recipe the day before yesterday can now be a little less confused (hopefully): here’s the explanation.
The program is written in an esoteric programming language called Chef, who’s sole purpose is to be able to write computer programs that look like recipes. There are even competitions to write programs in it that can also be cooked as real dishes. It’s a strange world. Each of the ingredients is a primitive kind of variable (for the non-programmers: a named entity [eggs, penne pasta, etc.] that can contain a value). The values that these variables can be instantiated with are numbers, and the numbers are given at the start of the line. Therefore, at the start of the program, eggs=3 and penne pasta=56.
These are “put” into the mixing bowl one at a time. The mixing bowl is a stack – the things put in to it first appear at the bottom, with other things on top of it (for the non-programmers: stacks are immensely useful in almost all programming languages, so programmers tend to have no trouble with being told “the mixing bowl is a stack”). So, when the first item (penne pasta) is put into the mixing bowl, it (and it’s associated value, 76) sits at the bottom of the bowl, ready for other things to be “put” on top of it.
However, we do some more complicated things, such as “adding” a birds-eye chilli. “Adding” is not the same as “putting”. When something is “added” to the mixing bowl, the value of it’s ingredient is added, mathematically, to the value of the thing at the top of the bowl. So, for example, when we add “1” birds-eye chilli to the mixing bowl which contains only “76” grams of penne pasta, we end up with a mixing bowl containing just “77” grams of penne pasta.
“Combining” is another Chef operation. After we’ve put the fresh ginger (17) in, we combine it with the cinammon (5), which results in a multiplication of the top item in the bowl, resulting in 85. “Removing” the birds-eye chilli (1) reduces this number by 1, because the “remove” operation means “reduce the value of the ingredient from the value of the ingredient in the top of the mixing bowl”. Later, we “stir”, the mixture, which moves some of the values in the stack around (read the spec if you care). And eventually, we “liquefy” the contents of the mixing bowl, which turns the numbers into their Unicode equivilent (typically letters): N, A, M, T, A, C, and S.
The baking tray is the output buffer (buffet?) in which things must be placed to be output to the screen, and the “serves” directive indicates which baking tray (we only have one in my recipe, but the language specification allows for multiple bowls, trays, and even delegation of sauces and other side dishes to other chefs – see the recipe for Fibonacci Numbers with Caramel Sauce [and notice the recursion – “caramel sauce should be served with caramel sauce”]) we output to the screen.
Jon earns himself a pint from working through the program, the mad fool that he is. There was a flaw in his logic, though, that made him come up with “NAMTACS” as the answer: he forgot that the baking tray, too, is a stack, and that the order of the ingredients is not changed in the transfer from the mixing bowl to the baking tray (check the spec!)… when popping ingredients out of the baking tray, they come out in reverse order. A pint to Paul for spotting his mistake. The correct output is “SCATMAN”.
Thanks to David Morgan-Mar for this fantastic programming language. He’s also the man behind LenPEG, an image compression algorithm which, for selected images, can achieve lossless compression at a ratio of 6,291,456:1, and HQ9++, an object-oriented language which provides the most code-efficient possible method ever to write test programs such as Hello World, 99 Bottles Of Beer, and the Quine program, although nobody has ever successfully written a Fibonacci generator or a Towers of Hanoi solver in it.