Exercises for Week 10

Exercise 00

  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. Time permitting, do peruse the lecture notes of this week, reproducing their OCaml content.

Mandatory exercises

  1. Exercise 01 from Week 10: about compare and make_comparison
  2. implement a polymorphic function, list_length : 'a list -> int, that computes the length of a list
  3. implement a polymorphic function, list_append : 'a list -> 'a list -> 'a list, that concatenates two lists
  4. implement a polymorphic function, list_map : ('a -> 'b) -> 'a list -> 'b list, that maps a given function over the elements of a given list and that returns the list of the results
  5. implement a polymorphic function, list_reverse : 'a list -> 'a list, that reverses a list
  6. solve Exercise 02 from Week 10: about right-to-left lists (i.e., tsils)
  7. Exercise 06 from Week 08: about list_map
  8. Exercise 09 from Week 08: about list_mapi
  9. Exercise 02 from Week 09: about function equivalences
  10. Exercise 10 from Week 09: about list_fold_right
  11. Exercise 16 from Week 09: about list_fold_left
  12. Exercise 06 from Week 10: about testing random binary trees of integers
The fourth wall: Friendly reminder – parentheses are for tuples, and square brackets are for lists.

Optional exercises (for the overachievers)

  1. Exercise 07 from Week 08: unzipping a list of pairs
  2. Exercise 25 from Week 09: about the power function
  3. Exercise 30 from Week 09: finding the smallest and the largest elements of a given list
  4. Exercise 33 from Week 09: zipping a pair of lists
  5. Exercise 07 from Week 10: generating random data
  6. Exercise 11 from Week 10: about binary trees with payloads in their nodes

Version

Fixed a typo in the second mandatory exercise, thanks to Gytis Greicius’s eagle eye [06 Apr 2022]

Added the friendly reminder [29 Mar 2022]

Added the weekly exercises [27 Mar 2022]

Created [26 Mar 2022]

Table Of Contents

Previous topic

The slash type error

Next topic

Lecture Notes, Week 11