+
+ where `new_peg_and_assign` is the operation we defined in [hint 3](/hints/assignment_7_hint_3):
+
+ let new_peg_and_assign (var_to_bind : char) (d : entity) =
+ fun ((r, h) : assignment * store) ->
+ (* first we calculate an unused index *)
+ let newindex = List.length h
+ (* next we store d at h[newindex], which is at the very end of h *)
+ (* the following line achieves that in a simple but inefficient way *)
+ in let h' = List.append h [d]
+ (* next we assign 'x' to location newindex *)
+ in let r' = fun v ->
+ if v = var_to_bind then newindex else r v
+ (* the reason for returning true as an initial element should now be apparent *)
+ in (true, r',h')