CS 421: Programming Languages and Compilers

Syllabus and Study Guide for Midterm 1

Studying for this exam

[top]

  • Understand the lecture slides and discussions thoroughly.
  • Solve relevant problems in the Exam Database.
  • Revisit the MPs and make sure you understand the solutions thoroughly. Repeat any you are not comfortable with.
  • Take the sample exam as a dry-run for the actual exam.

Syllabus

[top]

The exam will cover the first 9 lectures, up to and including user defined types (\texttt{datatye}s and records) and defining functions over them. The following give examples of the kinds of questions you are likely to be asked for each topic:

  • Basic OCaml
    • Know the basic constructs (e.g., match, fun, let, let rec) like the back of your hand.
    • Be able to evaluate OCaml expressions
    • Be able to determine the type of OCaml expressions
    • be able to describe the environment that result from a sequence of declarations
    • be able to describe the closure that is the result of evalutating a function declaration
  • Recursion
    • Be able to write recursive functions, possibly tail-recursive.
    • Be able to recognize whether a function is tail-recursive, and when a recursive call is in tail call position
    • Understand the performance benefits of tail recursion.
  • Higher Order Functions (HOFs)
    • Be able to write the definitions of the common HOFs.
    • Be able to use map and fold to implement other functions, as in MP1.
    • Be able to write functions which use other functions as arguments
  • User-Defined Types
    • Be able to define record types and disjoint (variant) types in OCaml.
    • Know the difference between record and disjoint types, and when each should be used.
    • Be able to write OCaml functions over recursive disjoint types.