Computer Science 3675
Fall 2014
Practice Questions for Quiz 2

  1. What is the difference between a strongly statically typed language and a weakly statically typed language?

    Answer

  2. What is the defining characteristic of a dynamically typed language?

    Answer

  3. Given the definition

        f([])   = []
        f(h::t) = (h*h)::f(t)  when h > 10
        f(h::t) = f(t)         when h ≤ 10
    
    show an inside-out evaluation of expression f([4,12,15,6,11]). Show the entire expression at each step. Assume that arithmetic is done as soon as possible.

    Answer

  4. Suppose that function f in the preceding problem is is restricted to lists of integers. What is the type of f?

    Answer

  5. Write an equational definition of a function called smallest so that smallest(n,x) is the smallest member of list n::x. For example, smallest(3, [6,4,7]) = 3 and smallest(8, [2,5]) = 2. You may presume that you have a function called min that takes the minimum of two numbers. For example, min(7,4) = 4.

    Answer

  6. Show an inside-out evaluation of smallest(4, [2,6,1]), using your definition from the preceding question.

    Answer

  7. Suppose that function f is defined by

    f(x,y) = (y, head(x))
    what is the most general polymorphic type of f? Use Greek letters for type variables.

    Answer