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.
-
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
Which of the following expressions would generate the intended behavior when used to fill in the blank in the toggle
function definition? Check all that apply.
A. b := not c; c
B. b := c; c
C. b := not c; !b
D. b := not c; not !b
E. b := !c; not c
F. not c; b := not c
G. None of the above