fork/numbat

git clone https://git.julia.blue/fork/numbat

David PeterString interpolation with arbitrary sub-expressions!c354c09

v1.8.0
427 B15 linesraw
1# Scale ingredient quantities based on desired servings.
2
3@aliases(servings)
4unit serving
5
6let original_recipe_servings = 2 servings
7let desired_servings = 3 servings
8
9fn scale<D>(quantity: D) -> D =
10    quantity × desired_servings / original_recipe_servings
11
12print("Milk:          {scale(500 ml)}")
13print("Flour:         {scale(250 g)}")
14print("Sugar:         {scale(2 cups)}")
15print("Baking powder: {scale(4 tablespoons)}")