Skip to content
Permalink
master
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
(*Used when trying to look up a name that doesn't exist*)
exception NameNotBound of string;
(*Used to store the list of current bindings, each with a var name and value*)
type Env = (string * int) list;
(*Creates an empty environment*)
fun env_new () : Env = nil;
(*Adds a new element with the given name and value to the front of the given Env list*)
fun env_bind (e : Env) name num : Env = (name, num) :: e;
(*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 (nil : Env) name = raise NameNotBound name
| env_lookup (e: Env) name = if name = #1 (hd e) then #2 (hd e) else env_lookup (tl e) name;