Homework 5  -- Due July 7
Programming Languages G22.2110-001 Summer 2004
1.  (2 pts) Write an ML function that reverses the contents of a list. For example, rev [1, 2, 3] is [3, 2, 1];

2.  (3 pts) A palindrome is a list which reads the same backward or forward. For example, "A MAN A PLAN PANAMA" or "ABBA" or [1, 2, 2, 1].  Write an ML function that determines whether a list is a palendrome or not.

3. (5 pts) The outer product of two vectors applies a specified operator op, to every pair of elements from the two vectors, S and T. The result is a matrix M in which each element m of M is the result of  s op t, where s is an element of S and t is an element of T .
This is best explained by an example:  outer_product +  [1, 2, 3]  [1, 2, 3, 4]  is
          2  3  4  5
          3  4  5  6
          4  5  6  7
The top row is the result of adding the first element of the first vector to each element of the second, the second row is the result of adding the second element of the first vector to every element of the second vector and so on.  Addition is not the only operator that can be used :
     outer_product * [1, 2]  [1, 2, 3] is
          1  2  3
          2  4  6
Your assignment is to write a function in ML that performs the outer product.  You should represent your array as a list of lists, i.e. a list in which each element is a list representing one row of the matrix. Hint: It may be useful to define helper functions, which you can define in let statements, Also, it may be helpful to define a function that does addition, multiplication, etc. rather than trying to use the normal infix operators.