X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=code%2Fcalculator%2Fcalc5.ml;h=f855c88c8dba9b728e9fbf170585cd7d13c6f432;hp=2f533af3a2aad60def4c827e72336c61b7dc84a2;hb=c51397c5a41cbf75e37382905b212868e427b16b;hpb=38f178b5967f0875383d87a92330ecd58979f83e diff --git a/code/calculator/calc5.ml b/code/calculator/calc5.ml index 2f533af3..f855c88c 100644 --- a/code/calculator/calc5.ml +++ b/code/calculator/calc5.ml @@ -1,4 +1,4 @@ -(* calc3,ml, enhanced with Mutable Pairs *) +(* calc5.ml: calc3,ml enhanced with Mutable Pairs *) type term = Intconstant of int @@ -94,12 +94,12 @@ (* we don't handle cases where t1 doesn't evaluate to a Pair *) let (Pair (index1, index2), s') = eval t1 g s (* note that s' may be different from s, if t1 itself contained any mutation operations *) - in let (new_value, s'') = eval t2 g s' - (* now we create a list which is just like s'' except it has new_value in index1 *) + in let (value2, s'') = eval t2 g s' + (* now we create a list which is just like s'' except it has value2 in index1 *) in let rec replace_nth lst m = match lst with | [] -> failwith "list too short" - | x::xs when m = 0 -> new_value :: xs + | x::xs when m = 0 -> value2 :: xs | x::xs -> x :: replace_nth xs (m - 1) in let s''' = replace_nth s'' index1 in (Int 42, s''')