Lab 15

Lab 15 Instructions #

Reminders #

  • We’re releasing lab access a day or two earlier so that you can take a look over the lab ahead of time to save some reading time. That will probably be especially helpful for the remaining labs.

  • If you haven’t already, please go ahead and download the lab materials in preparation for the start of the lab proper. (But please wait until you’re instructed before beginning work on the lab.)

  • One laptop at a time per pair of partners.

  • Swap drivers at each exercise. Nobody likes a driving hog.

  • High five when you solve a problem. Why not? It just feels right.

  • Do you have hints about the course? Let me know: shieber@seas.harvard.edu.

Setup instructions #

Head to http://url.cs51.io/lab15 and follow the Lab Procedures.

Lab puzzle #

Consider the following two integer expressions that make use of the Lazy module (which you can assume has been opened already):

let n1 = let r = ref 0 in
         lazy (r := !r + 1;
               !r) in
force n1 - force n1 ;;

let n2 = lazy (let r = ref 0 in
               r := !r + 1;
               !r) in
force n2 - force n2 ;;

Which of these two expressions is greater?

A. The first expression is greater

B. The second expression is greater

C. The two expressions are the same