CIS 554 -- Final Exam Name __________________________________

Read each question at least twice. Keep answers short and to the point. Do not provide any information that was not asked for; you may lose points that way.

  1. (5 points) Complete the following definition as precisely as you can.

         In resolution theory, a clause is...

  2. (8 points) Unification is an essential operation in Prolog. For each of the following, tell (1) whether the two expressions can be unified (answer "yes" or "no"), and (2) if "yes," what values are given to each of the variables. (Remember, variables begin with a capital letter.)
    1. f(X, Y) = g(5, 7)
    2. mother(john, Dick) = mother(Jack, richard)
    3. mother(tom, Dick) = mother(Dick, harry)
    4. Me = grandpaw(Me, myself)

  3. (5 points) Here is some code from one of my REBOL programs:
         last-part:  last  split-path  pick  image-files  n  clear  find  last-part  #"."
    where last, split-path and clear are functions that take a single argument, pick and find are functions that take two arguments, and image-files and n are data values. Add parentheses to this line to make the structure explicit.

  4. (10 points) REBOL does not have map or filter functions.

    1. Would it be possible to write these functions in REBOL? (I am not asking you to write them!). Answer "yes" or "no" and give a reason for your answer.

    2. Is REBOL a functional language? Answer "yes" or "no" and give a reason for your answer.

  5. (5 points) What is the difference between the way a call to a macro is processed, and the way a call to a function is processed? (Be sure to specify which is which.)

  6. (5 points) A Java class (or Scala class, it doesn't matter) named WaitList has an instance variable private Queue<String> queue. The only accesses to this object are by instance methods synchronized void add(String s) and synchronized String remove().

    1. What object is being used as the monitor?

    2. Is this sufficient to make the queue object thread safe?

    3. Why or why not?

  7. (8 points) When using Software Transactional Memory (STM),

    1. What causes a transaction to fail?

    2. What happens when a transaction fails?

  8. (5 points) Using an example, write a description of currying.

  9. (5 points) Suppose you have a program to evaluate a large variety of calculus expressions. The methods that do the evaluations are recursive, but most are not tail recursive.

    1. What would be the advantage of rewriting them to be tail recursive?

    2. Besides the extra effort involved, what would be the disadvantage of rewriting them to be tail recursive?

    3. Should you rewrite them? Why or why not?

  10. (5 points) What is a race condition, and how can it be prevented?

  11. (5 points) What is deadlock, and what causes deadlocks to occur?

  12. (5 points) Briefly define:
           Metaprogramming is...

  13. (5 points) Briefly define:
           A persistent data structure is...

  14. (5 points) Briefly define:
           A list comprehension is...

  15. (5 points) In any functional language, lists are much more important than arrays, and are used much more often. Why?

  16. (4 points)
    1. The acronym DSL stands for the words:

    2. Give one example of a DSL:

  17. (5 points) Java and Scala both provide Futures.

    1. Briefly define:
             A Future is...

    2. Once you have started a Future, what are the three basic operations you can do with it?



  18. (5 points) Fill in the five blanks: