Lab 12 Instructions #
Reminders #
While students are coming into class, feel free to go ahead and download the lab materials in preparation for the start of the lab proper.
Ask for help from the staff. That’s what we’re here for. Even if you think you’ve solved a problem, you can have a staff member look it over for further advice.
We post lab solutions with extra information and ways of solving.
Setup instructions #
Head to http://url.cs51.io/lab12 and follow the Lab Procedures.
Lab puzzle #
Consider the following function definition with a blank in it:
let toggle =
let b = ref false in
fun () -> let c = !b in
________________________ ;;
It’s intended to have the following behavior:
# toggle () ;;
- : bool = true
# toggle () ;;
- : bool = false
# toggle () ;;
- : bool = true
# toggle () ;;
- : bool = false
A. b := not c; c
B. b := c; c
C. b := not c; not c
D. b := not c; not !b
E. c; b := not c
F. b := !c; not c
G. not c; b := not c
H. b := not c; !b
I. b := c; not c
J. None of the above.