A formal language for recipes: brain dump

Posted by Tom Moertel Fri, 08 Jan 2010 05:15:00 GMT

One of the projects I’ve had in the back of my mind for a few years is a formal language for recipes. Professional bakers have long used formulas to express the core of their recipes. And with Michael Ruhlman’s Ratio: The Simple Codes Behind the Craft of Everyday Cooking being so well received by geeky home cooks, it seems the time may be right to start hacking away.

As a brain dump, here are some syntax ideas I’m playing with. (BTW, if you want to learn how to make a pie from scratch, here you go. Use butter or lard for the fat if you’re serious about pie.)

-- classic recipe for 3-2-1 pie pastry

pie_crust:

  3 flour
  2 fat, cold
  1 water, ice cold

  yields 1 dough  -- (optional: default result is final item)

  flour_fat_mix:
    flour
    fat
    "cut fat into walnut-sized pieces" 
    "combine in chilled bowl" 
    "mix until fat is pea sized" 

  dough:
    flour_fat_mix
    water
    "add water while mixing gently" 
    "stop when shaggy dough begins to form" 
    "gently shape dough into portioned rounds by hand" 
    "wrap portions with film-wrap" 
    "refrigerate" 

-- pie, which uses the crust recipe above

pie_9_inch:

  24 oz pie_crust, chilled
   1 pie_tin, 9 inch, chilled
   1 filling, enough for 9-inch pie

  yields 1 pie, 9 inch

  bottom_shell:
    pie_crust
    pie_tin
    filling
    take pie_crust, 13 oz, "portion dough" 
    "roll into 11-inch round" 
    "line pie tin with dough" 
    "add filling" 

  top_shell:
    pie_crust
    take pie_crust, remainder
    "roll into 10-inch round" 

  pie:
    bottom_shell
    top_shell
    "top the pie, sealing edges well" 
    "trim excess dough from edges, decorating if desired" 
    "cut vent hole(s) in top" 
    "refrigerate for at least 30 minutes to set dough" 
    "bake at 425 degrees F for 15 minutes" 
    "reduce oven to 350 degrees F" 
    "bake until done, about an hour" 

Posted in
Tags , , , ,
12 comments
no trackbacks
Reddit Delicious

Wondrous oddities: R's function-call semantics

Posted by Tom Moertel Fri, 20 Jan 2006 23:02:00 GMT

Every so often, I am going to write about wondrous oddities – obscure programming-language features that are so cool they deserve wider notice. Today, in the first installment, I want to show you the function-call semantics of R, a great system for statistical computing.

You might not expect a statistics system to have a first-class programming language at it’s heart, but if you think about it, it does make sense. The R language, actually a dialect of the S language, is described as “a well-developed, simple and effective programming language which includes conditionals, loops, user-defined recursive functions and input and output facilities.” All true. It gives me the feeling of an infix Lisp or Scheme whose syntax is slanted toward mathematics and vector operations. The language has an object layer, too, but that’s not why we are here.

No, we are here to look at R’s uncommonly interesting function-call semantics, in particular argument binding and evaluation. Let’s dig in.

Read more...

Posted in , ,
Tags , ,
5 comments
no trackbacks
Reddit Delicious

Scope herding with delimited continuations

Posted by Tom Moertel Tue, 13 Sep 2005 14:24:00 GMT

Recently I took advantage of delimited continuations to create a more natural Haskell-based kernel for GIML. The amazing scope-herding abilities of reset and shift were the magic that made it possible.

Ready to get wild? Grab an espresso and read on.

Read more...

Posted in , ,
Tags , ,
2 comments
no trackbacks
Reddit Delicious