From 060198e29e2a13552ee64c1e489eea555c8b1cae Mon Sep 17 00:00:00 2001
From: Jim Pryor
Date: Thu, 25 Nov 2010 22:48:12 -0500
Subject: [PATCH] tweak calc improvements
Signed-off-by: Jim Pryor
---
advanced_topics/calculator_improvements.mdwn | 12 ++++++------
code/calculator/calc4.ml | 6 +++---
code/calculator/calc5.ml | 6 +++---
3 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/advanced_topics/calculator_improvements.mdwn b/advanced_topics/calculator_improvements.mdwn
index b36f6287..720d961a 100644
--- a/advanced_topics/calculator_improvements.mdwn
+++ b/advanced_topics/calculator_improvements.mdwn
@@ -465,12 +465,12 @@ Now we need to formulate the clauses for evaluating the new forms `Newref (...)`
(* we don't handle cases where t1 doesn't evaluate to a Mutcell *)
let (Mutcell index1, 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
(* we'll arbitrarily return Int 42 as the expressed_value of a Setref operation *)
@@ -538,12 +538,12 @@ Finally, here are the changed or added clauses to the evaluation function:
(* 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''')
diff --git a/code/calculator/calc4.ml b/code/calculator/calc4.ml
index 27687d57..54519f0c 100644
--- a/code/calculator/calc4.ml
+++ b/code/calculator/calc4.ml
@@ -105,12 +105,12 @@
(* we don't handle cases where t1 doesn't evaluate to a Mutcell *)
let (Mutcell index1, 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
(* we'll arbitrarily return Int 42 as the expressed_value of a Setref operation *)
diff --git a/code/calculator/calc5.ml b/code/calculator/calc5.ml
index 2f533af3..593f296b 100644
--- a/code/calculator/calc5.ml
+++ b/code/calculator/calc5.ml
@@ -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''')
--
2.11.0