CS323: Programming Languages and Methodologies
Homework Project 3
Assigned April 24
Due in class Friday May 4


1) Write a well designed evaluator function "value" for arithmetic expressions on sets. Your evaluator should handle the following binary operations on sets:

+ : for set union
- : for set difference
* : for set intersection
% : for symmetric difference
You are to represent sets simply as list of atoms with no repeats. Here are some sample evaluations:

(value '( (a b c) + (c d e))) is (a b c d e)
(value '( (a b c) - (c d e))) is (a b)
(value '( (a b c) * (c d e))) is (c)
(value '( (a b c) % (c d e))) is (a b d e)
(value '( (a b c d e f) * ( (((a b) + (c e)) - (c d)) % (a b c d e)))) is (c d)

2) A parallel prefix computation takes as arguments a lat and a binary associative operation (like + or *) and returns the list of all partial products. E.g.,

(par-prefix '+ '(1 2 3 4 5)) is (1 3 6 10 15)
(par-prefix '* '(1 2 3 4 5)) is (1 2 6 24 120)

Write two Scheme functions, one for parallel prefix computation applied to lats, and another function par-prefix$ to work for streams. For example,

(stream-to-list (par-prefix$ '+ primestream) 6) is (2 5 8 15 26 39)