# Cooking Ingredient Converters

## Cooking Ingredient Converters

These cooking ingredient converters are a proof of concept for the notion of merging recursive forms (RFs).
Sweetener Converter
Sugar Converter
Milk Converter
Dairy Converter
A-C Flour Converter
D-O Flour Converter
P-R Flour Converter
S-W Flour Converter

### Background

These tools, in the modality of cooking ingredient converters, are a proof of concept for the notion of merging different recursive forms (RFs). This time, we merged RFs for volume and mass conversions.

RFs automatically submit themselves when a user completes the following steps (see Theory section).

1. Select an initial option or accept the default one.
2. Input a value compatible with said option.
3. Select a new option.

### Examples

It is common in cake recipes that the sugar in the cake should be equal to the weight of the flour. If a recipe asks for 1 measuring cup of granulated sugar, how much of all-purpose flour (sifted) is needed?

To answer that question, let use our sugar and flour converters. Because there are way too many different types of flours, these are listed in alphabetical order (A-C, D-O, P-R, and S-W) across several converters. Thus all-purpose flour is listed in the A-C Flour Converter whereas granulated sugar is listed in the Sugar Converter.

Selecting the "cup, US (c)" option from the Sugar Converter, entering 1, and switching to the "granulated sugar (g)" option, indicates that 1 cup of granulated sugar is about 200 g. Repeating this exercise, but this time with the A-C Flour Converter, it turns out that 1 cup of all-purpose flour (sifted) is about 120 g.

That gives us a mass ratio of about 200/120 = 1.6. This ratio is also the density ratio of the ingredients. So if a recipe asks for 1 cup of sugar, we may use 1 cup + 2/3 cup of flour. Done!

Note please that these are mere estimates. Certainly the most accurate way to measure cooking ingredients is with a digital kitchen scale. If one is not available, ingredient amounts can be estimated using conversion tables, measuring cups, and some math. The RFs listed in this web page were designed to simplify these tasks.

RFs similar to these can be implemented in a science lab setting. After all, measuring, weighing, mixing, stirring, decanting,... are all processes used in kitchens and laboratories.

That reminds me of something I wrote a while ago (Garcia, 1995):

"If I have a theory, but no experimental results,
I may have nothing.
And If I have a theory without practical applications,
I may have an artifact."

### Discussion

We define a recursive form (RF) as an HTML form where the name/value pairs of successful controls are recursively generated through the decision-making process of users.

### Algorithm

The algorithm implemented by these RFs is based on a one-dimensional associative array of the form

$index = [ "unit_1" => "value_1", "unit_2" => "value_2", ⋮ ];  where$index is obtained by merging an associative array of volumes with an associative array of masses, computed at run time as density-weighted volumes.

Upon submission:

• The initial option and input value become the name/value pair of a dynamically generated hidden field.
• The values of the new and initial options are located in the index and their ratio taken so a scaling ratio is computed.
• The initial input value is multiplied by the scaling ratio, and the result displayed in the input field as the new value.

Users can repeat this process as many times as they wish to by simply switching to a new option.

### Exercises

• Prove that the mass ratio given in the example is the same as the density ratio of sugar and flour.
• Using the Milk Converter, estimate the density of whole milk in g/mL.