Advanced Functional Prog.


Packages' Builder

C. Sets

  1. By using, the previous lists' functions, define standard sets' operator with:
    a. elem x xs that tests if x belong to the list/set xs
    b. inter xs ys that returns the common elements from two lists
    c. disjoint xs ys that tests that two sets have no common elements
    d. diff xs ys that returns the elements from xs not in ys
    e. union xs ys that returns the elements contained both in xs or ys. Nb. use (@) and diff to be sure a value appears once.
    f. bigUnion that returns the union of a set of sets.
    g. allDisjoin that tests that all the sets of a set are disjoin
    h. subset xs ys that tests that all the elements from xs are in ys
    i. equals xs ys thats tests that xs is a subset of ys, and xs a subset of xs
    j. power xs that returns the set of all the subsets of xs (and is called the "powerset"),
    eg. power (0<>1) =[[];[1];[2];[1;2]]

answers