tweak calc improvements
authorJim Pryor <profjim@jimpryor.net>
Thu, 25 Nov 2010 16:26:00 +0000 (11:26 -0500)
committerJim Pryor <profjim@jimpryor.net>
Thu, 25 Nov 2010 16:26:00 +0000 (11:26 -0500)
Signed-off-by: Jim Pryor <profjim@jimpryor.net>
advanced_topics/calculator_improvements.mdwn

index 013b9a6..4ddff27 100644 (file)
@@ -52,12 +52,12 @@ We'll add one boolean predicate, `Iszero`, and an `If...` construction.
 
 We won't try here to catch any type errors, such as attempts to add a `bool` to an `int`, or attempts to check whether a `bool` iszero. Neither will we try here to monadize anything: these will be implementations of a calculator with all the plumbing exposed. What we will do is add more and more features to the calculator.
 
 
 We won't try here to catch any type errors, such as attempts to add a `bool` to an `int`, or attempts to check whether a `bool` iszero. Neither will we try here to monadize anything: these will be implementations of a calculator with all the plumbing exposed. What we will do is add more and more features to the calculator.
 
-We'll switch over to using variable `g` for assignment functions, which is a convention many of you seem familiar with. As we mentioned a few times in week 9, for some purposes it's easier to implement environment or assignment functions as functions from `char`s to `int`s (or whatever variables are bound to), rather than as lists as pairs. However, we'll stick with this implementation for now. We will however abstract out the type that the variables are bound to. For now, we'll suppose that they're bound to the same types that terms can express.
+We'll switch over to using variable `g` for assignment functions, which is a convention many of you seem familiar with. As we mentioned a few times in week 9, for some purposes it's easier to implement environment or assignment functions as functions from `char`s to `int`s (or whatever variables are bound to), rather than as lists of pairs. However, we'll stick with this implementation for now. We will however abstract out the type that the variables are bound to. For now, we'll suppose that they're bound to the same types that terms can express.
 
        type bound_value = expressed_value;;
        type assignment = (char * bound_value) list;;
 
 
        type bound_value = expressed_value;;
        type assignment = (char * bound_value) list;;
 
-Here's where we should be now:
+Here's where we should be now. We expand some of the clauses in the `eval` function for clarity:
 
        type term = Constant of int
                | Multiplication of (term * term)
 
        type term = Constant of int
                | Multiplication of (term * term)