By way of analogy, suppose I'm baking cookies. I look at the recipe and see that it calls for eggs, chocolate, sugar, more chocolate, butter, flour, and more chocolate. Before I start mixing things together, I get all the ingredients out and put them on the counter to make sure I've got everything I need (or whether I have to run to the store for more chocolate). That's basically what a function inventory is: we're putting all the "ingredients" in one place so we can see them before starting to mix them together.
Suppose we already have the contract and skeleton
; cube : number -> number (define (cube num) ... )For this simple example, the inventory would simply point out that the parameter
num
will almost certainly need to appear in the
body, and that it represents a number:
; cube : number -> number (define (cube num) ; num number ... )
If your function has multiple parameters, list them all, each on a separate line:
; checkerboard : string (color1) string (color2) number (size) -> image (define (checkerboard color1 color2 size) ; color1 string ; color2 string ; size number ... )
As the data types get more complex, so will the inventories. For
example, if one of your input data types is a posn
, the
inventory should show the most likely things to do with that
posn
:
; distance-to-origin : posn -> number (define (distance-to-origin where) ; where posn ; (posn-x where) number ; (posn-y where) number ... )