Lab 2: SML, Flex & Bison, and Automake & Autoconf

  1. Flex and Bison
  2. Automake & Autoconf
  3. SML Basics
  4. SML Exercises
    1. Write a function max of type int list -> int that returns the largest element of a list of integers. Your function need not behave well if the list is empty. Hint: Write a helper function maxhelper that takes as a second parameter the largest element seen so far. Then you can complete the exercise by defining fun max x = maxhelper(tl x, hd x);
    2. Write a function to test whether an element is a member of a set. For example isMember(x, l) would return true if x is an element in the list l, and false otherwise.
    3. Write a function to construct the union of two sets, ie. union(x, y) where both x and y are lists, and union(x, y) would return a list of unique elements, each of which belongs to either list x or y.
    4. Write a function to construct the intersection of two sets. ie. intersect(x, y) where both x and y are lists, and intersect(x, y) would return a list of unique elements, each of which belongs to both list x and y.