Solved-Assignment 01 -Solution

$30.00 $19.00

1. Write a function subset a b that returns true iff a⊆b, i.e., if the set represented by the list a is a subset of the set represented by the list b. Every set is a subset of itself. This function should be generic to lists of any type: that is, the type of subset…

You’ll get a: . zip file solution

 

 

Description

5/5 – (2 votes)

1. Write a function subset a b that returns true iff a⊆b, i.e., if the set represented by the list a is a subset of the set

represented by the list b. Every set is a subset of itself. This function should be generic to lists of any type: that is,

the type of subset should be a generalization of ‘a list -> ‘a list -> bool.

2. Write a function equal_sets a b that returns true iff the represented sets are equal.

3. Write a function set_union a b that returns a list representing a∪b.

4. Write a function set_intersection a b that returns a list representing a∩b.

5. Write a function set_diff a b that returns a list representing a−b, that is, the set of all members of a that are not also

members of b.

6. Write a function computed_fixed_point eq f x that returns the computed fixed point for f with respect to x, assuming that

eq is the equality predicate for f’s domain. A common case is that eq will be (=), that is, the builtin equality predicate

of OCaml; but any predicate can be used. If there is no computed fixed point, your implementation can do whatever it wants:

for example, it can print a diagnostic, or go into a loop, or send nasty email messages to the user’s relatives.

7. Write a function filter_reachable g that returns a copy of the grammar g with all unreachable rules removed. This function

should preserve the order of rules: that is, all rules that are returned should be in the same order as the rules in g.