// A woodworking and baking site: measures read as people write them ("1 1/2", "3/8", "⅜"),
// summed exactly, decimals turned back into fractions, cuts rounded to the nearest 1/16 inch,
// and a recipe scaled for more guests.
//
//   quillo run fractions.qwe      then open http://localhost:8080/workshop and http://localhost:8080/recipe

use "fractions.qwer"

route GET /workshop = {
    board: frac_read("2 3/8")?,
    sum: frac_calc("1 1/2", "+", "⅜")?.mixed,
    kerf: frac_eval("(96 - 3 * 1/8) / 4")?.mixed,
    pi: frac_from_decimal(3.14159265, 1000)?.text,
    third: frac_from_decimal(0.333, 10)?.text,
    cut: frac_round(23.4567, 16, "in")?,
    equal: frac_compare("2/6", "1/3")?,
    percent: frac_read("12.5%")?.text,
    zero: frac_eval("1/(2-2)").error,
}

route GET /recipe = frac_scale_recipe(["2 1/4 cups flour", "3/4 cup sugar", "1 egg", { qty: "1/3", unit: "cup", item: "milk" }, "a pinch of salt"], "3/2")?
