Exercises for Week 09

Exercise 0

  1. At the top right and at the bottom right of the present page, there is a clickable word, “index”, to access the index of the current version of the lecture notes. Click on it and then peruse the index, making sure that its entries make sense to you (otherwise, click on them to check them out).
  2. The lecture notes start with updates (Chapter Lecture Notes for Intro to CS, updates). Make sure to check them out regularly, as they reflect the development of the lecture.
  3. Do take the time to peruse the lecture notes of this week and to reproduce their OCaml content.

Mandatory exercises

None, due to the midterm project.

Optional exercises

None, due to the midterm project.

Exercise 36

  1. Using The logical counterpart of the map function for lists, from Week 08, i.e., list_andmap, implement a predicate that checks whether a given list only contains integers that lie between -16 and +16, exclusively.
  2. Using List.init, Random.int, and Random.bool, implement an OCaml function that, when applied, constructs a list of random length that contains random integers lying between -15 and 15, inclusively.
  3. Consider the unit-test function for the implementation in Part a., the implementation in Part a., the unit-test function for the implementation in Part b., and the implementation in Part b. How do these OCaml functions relate with each other?
  4. Using words like “developers” and “testers”, characterize the rôles of the people who implemented the unit-test function for the OCaml function in Part a., the OCaml function in Part a., the unit-test function for the OCaml function in Part b., and the OCaml function in Part b.

Version

Created [19 Mar 2022]

Table Of Contents

Previous topic

The polymorphic option type

Next topic

Lecture Notes, Week 10