X-Git-Url: http://lambda.jimpryor.net/git/gitweb.cgi?p=lambda.git;a=blobdiff_plain;f=code%2Funtyped_evaluator_complete.ml;fp=code%2Funtyped_evaluator_complete.ml;h=d9b158c6af361b3c7a0bf15b18bb2ebc44ba659d;hp=ed34138dc78b31e89ffa4b63db9d6cb48128fc0a;hb=86a3a58658e1b6466ec3cef5265f7de9df321713;hpb=9f2a492061f145772189b487e42fada185ef114b diff --git a/code/untyped_evaluator_complete.ml b/code/untyped_evaluator_complete.ml index ed34138d..d9b158c6 100644 --- a/code/untyped_evaluator_complete.ml +++ b/code/untyped_evaluator_complete.ml @@ -56,16 +56,16 @@ and result = term (* This simplified code just provides a single implementation of environments; but the fuller code provides more. *) -and env = identifier -> term option +and env = (identifier * term) list (* Operations for environments *) -let empty = fun _ -> None -let shift (ident : identifier) binding env = - fun (sought_ident : identifier) -> - if ident = sought_ident - then Some binding - else env sought_ident -let lookup sought_ident env = env sought_ident +let empty = [] +let shift (ident : identifier) binding env = (ident,binding) :: env +let rec lookup (sought_ident : ident) (env : env) : term option = + match env with + | [] -> None + | (ident, binding) :: _ when ident = sought_ident -> Some binding + | _ :: env' -> lookup sought_ident env' (*