CSCI 6220 programming assignment 1

  1. (Ex. 10.7 of Sethi) Suppose that sets are implemented as lists, where each element of a set appears exactly once in the list. Define functions that implement the following operations.

    1. Test whether a value is a member of a set.
    2. Construct the union of two sets.
    3. Construct the intersection of two sets.
    Implement each of the operations in Astarte. Write an execute block that tries the functions on a few values and prints the answer.

  2. (From ex. 10.11 of Sethi) Fill in the blanks in the following, using the standard Astarte functions, to make the equations true for all x and y. You can define helper functions if you like.

    1. rfold (______, ______) x = length(x)

    2. rfold (______, ______) x = x ++ y (or concat(x,y))

    3. rfold (______, ______) x = map f x

    Implement each in Astarte and test it on a few inputs.