Lab 12 Instructions #
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 (http://mydigitalhand.org). 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 #
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.
b := not c; c
b := not c, not c
b := c; c
b := not c; not c
b := not c; not !b
c; b := not c
b := !c; not c
not c; b := not c
b := not c; !b
b := c; not c