2

I'm working on a recipe definition language which uses operands ("milk", "eggs"), unary operators ("slice", "chop"), and binary operators ("combine", "fold in"). To avoid ambiguity, I've decided to use postfix/reverse Polish notation, so an example simple recipe would look as follows:

* eggs, 3 =beat
* cream, 1 Tbsp /add
* salt /add
* pepper /add =cook, over medium heat =stir

Operands would be *, = are unary operators, / represent binary operators.

Now, I'm facing a issue with recipe steps that require splitting ingredients in order to perform different operations on them. An example could be beating eggs together, and then using half now for a batter, and the rest later on for brushing the cake with. An idea I have would be an operator that splits an operand into multiple portions.

Is this something that is theoretically possible in RPN? Even if so, are there any kinds of recipes that couldn't be represented if I do this (for example, each of the split elements is processed separately and only recombined much further down the line)?

  • 1
    I don't have the answer, but I think the neatest way to implement this is to have an operator that can insert items deeper into the stack. For example, if you have "1 egg, 3, split", it splits the egg and inserts one half at the end of the stack, and the other half three elements from the top of the stack. – LinAlg Sep 29 '16 at 01:48

0 Answers0