3460:430/530:080             Theory of Programming Languages                                                       Fall 2003

Dr. C.-C. Chan                                                                                                                           Due:  11/30/03

Project #5  (25 pts)

 

Problem:  Write the following lisp functions

 

  1. Write a lisp function delete-all that takes two parameters, an atom and a list, and it returns the list with all occurrences, no matter how deep, of the given atom deleted.
  2. Write a lisp function mymerge that merge two ordered lists of numeric atoms.  You may assume that the two arguments are already sorted in ascending order.  For example,

(mymerge '(1 3 5 7) '(2 4 6))  returns  (1 2 3 4 5 6 7)

Don't use the built-in merge, sort, or insert functions.  The merge time should be proportional to the length of the longer of the two lists.

  1. Write a lisp predicate function equal-struct that tests for the structural equality of two given lists.  Two lists are structurally equal if they have the same list structure, although their atoms may be different.

4.   Write a lisp function sumset that takes a positive integer N and a list of positive integers L, determine if there is any set of elements in L whose sum is N.  If there is, return a list of those elements; if not, return nil.  For example,
(sumset  21  '(5 7 12 3 8)) returns nil
(sumset  20 '(5  7  12  3  8)) could return (5  12  3), (5  7  8), or (12  8)


5.    Convert an arithmetic expression written in Lisp prefix notation to postfix notation.  You may assume that all operators are binary operators.  For example,

            (postfix '(* a b))  returns (a b *)

     (postfix  '(*  (+  a b) (-  c d))  ) returns  (a b + c d - *)

 

Notes:

         You must use the same function names as given in the problems indicated by boldface names.

 

Submissions:

1.  Name your source file “your_uid.lisp”.

2.  Send the source file by e-mail to rthimma@uakron.edu and chan@cs.uakron.edu

3.  The project is due by midnight of the due day.