Higher-Order Programming » Lab Sessions
Session 6
Assistant: Steven Keuchel (steven.keuchel@vub.be)
Section 1: Environment Diagrams
Exercise 1: A Functional Environment Diagram
Using pen and paper, draw an environment diagram of evaluating (square 5)
and
(f 5)
using the following definitions. You do not need to draw the definition
of these 3 procedures.
Exercise 2: A Recursive Environment Diagram
The following is a solution of an earlier exercise.
Draw an environment diagram when evaluating (add-to-end (list 1 2 3) 5)
.
Exercise 3: A Lexical Environment Diagram
Using pen and paper, draw an environment diagram of evaluating the following program.
What is the displayed in the REPL? Is this the result you expected? What would be the result if Scheme had a dynamic scope (instead of a lexical scope)?
Exercise 4: A Functional Environment Diagram with Local Immutable State
Using pen and paper, draw an environment diagram of evaluating (increment10 20)
and using the following definitions. Include the definitions of the two
procedures in your diagram.