-(* calc3,ml, enhanced with Mutable Pairs *)
+(* calc5.ml: calc3,ml enhanced with Mutable Pairs *)
type term =
Intconstant of int
(* 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''')