Recipe Recursion
Opened this issue · 2 comments
Some recipes need ingredients that in turn have their own recipe. I've been trying to decide a way to handle this for years. It's time to actually track my progress...
There's a simple way and a really complicated way. Right now I'm leaning towards a simple way because every time I think about the complicated way I make no progress. So. Here's my idea:
Currently, a regular ingredient can be written as "ingredient": 123
where the value is always number. For recursion, I think the simplest solution would be to assign the value as an object. Ingredients within that object could be checked against the master list to find recipes that have multiple uses. For example "Hollandaise" : { "Hollandaise" : 123 }
But this would also allow the flexibility of defining sub-recipes, e.g. "steps", that will not have any use in the master list such as a specific dipping sauce like so "garlic soy": {"soy sauce": 29, "garlic": 29}
. Note that the values must match the parent's portion size in that case. And of course, these effects would be able to combine. The most notable example is of course aiole. All aiole is just mayonnaise + something else but that means that if one of the ingredients comes in oil like anchovies you may as well build the mayonnaise itself using the oil the fish came in.
"Mayonnaise": {
"Room Temperature Egg Yolk": 52,
"Citric Acid (lemon)": 5,
"Oil (add slowly)": 108,
"Salt": 3
},
"Ceasar Salad": {
"Romaine Lettuce": 500,
"Ceasar Dressing": {
"Anchovies": 23,
"Mayonnaise": {"Mayonnaise": 155 },
"Mustard": 10,
"Worcestershire": 10,
"Balsamic Vinegar": 10
}
}
Which would initially render as:
500
Romaine Lettuce208
Ceasar Dressing 🔽23
Anchovies155
Mayonnaise ▶10
Mustard10
Worcestershire10
Balsamic Vinegar
Note that the 208
is a computed value. It is the sum of the sub-recipe's parts.
Note that the scalar for the mayo is 155/(52+5+108+3)
= 0.9226190476
so that when Mayonnaise is expanded, the values from the initial recipe will be slightly smaller
500
Romaine Lettuce208
Ceasar Dressing 🔽23
Anchovies155
Mayonnaise 🔽48
Room Temperature Egg Yolk5
Citric Acid (lemon)100
Oil (add slowly)3
Salt
10
Mustard10
Worcestershire10
Balsamic Vinegar
Requirements:
- Accept object values to define sub-steps or sub-recipes
- Check against root for existing recipes
- Locally nested recipes should be expanded by default
- Globally recursive recipes should be collapsed by default (sometimes I don't feel like making the damn mayo)
- Sub-recipes not matched with the global list should have their initial scale set to
1.0
- Sub-recipes matched with the global list should be scaled up or down such that the sum of all ingredients, e.g. the "Total", matches the desired amount in the parent
- Scaling any ingredient should effect all parts of all recipes accordingly
I think before doing recursion, is there a way to denote which ingredients don’t scale?
for instance, red pepper flakes in a pasta sauce cause spice to grow exponentially. Maybe just add like 25% more?
sometimes ingredients are just there to catalyze. Like when poaching an egg, you just need a little bit of baking soda or vinegar to make the pH of the water different from the egg long enough that the egg white maintains cohesion long enough to cook. When you poach a 100 eggs, the water doesn’t need to be acidic enough to depolarize water.
Without recursion involved I could argue that these are two separate new issues.
- Spices in particular have been measured in a completely guessed way because often the portion in under a gram and the scale just can’t pick up how much was added; sometimes I’ve gone waaay over. I did not know that about red pepper 🌶 that’s crazy!
- Catalyists could fall under the larger umbrella of “instructions, prerequisites, and required tools” which I’ve been ignoring because I haven’t been here to teach people the skills; I just skip to the portion size and shut up