Skip to content
Permalink
14219b5067
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
17 lines (13 sloc) 672 Bytes
(*Used when trying to look up a name that doesn't exist*)
exception NameNotBound;
(*Maps a name as a string to its value as a given type*)
type 'a Env = string -> 'a;
(*Creates an empty Env which raises NameNotBound if var name a does not exist in Env*)
fun env_new () : 'a Env = fn x => raise NameNotBound;
(*Looks up the value of a given name in the given Env
Raises NameNotBound exception if name not found in the given Env*)
fun env_lookup (e : 'a Env) (x : string) : 'a = e x;
(*Adds a new element with the given name and value to the given Env*)
fun env_bind (e : 'a Env) (a : string) (b : 'a) : 'a Env =
fn (x : string) => if (x = a) then b
else e x;