Tuesday, March 6, 2007

EOPL - 2.3.3 - Exercise 2.20

It's simple to add new operations when the data is represented as an abstract syntax tree. Here's the operation has_association for stacks as defined in the previous exercise:

// Exercise 2.20
let rec has_association env sym =
match env with
EmptyEnv -> false
| ExtendedEnv (syms, vals, env') -> (List.mem sym syms) ||
(has_association env' sym)

No comments: