+ let new_peg_and_assign (var_to_bind : char) (d : entity) =
+ (* we want to return not a function that we can bind to a bool dpm *)
+ fun (truth_value : bool) : bool dpm ->
+ fun ((r, h) : assignment * store) ->
+ (* first we calculate an unused index *)
+ let new_index = List.length h
+ (* next we store d at h[new_index], 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 new_index *)
+ in let r' = fun var ->
+ if var = var_to_bind then new_index else r var
+ (* we pass through the same truth_value that we started with *)
+ in (truth_value, r', h')