Computer Science 3675
Fall 2015
Practice Questions for Quiz 3

  1. Scheme is a typeless language. What does that mean? Can type errors ever occur?

    Answer

  2. What is the value of Scheme expression (car (cdr (cons 'horse (cons 'zebra '( )))))?

    Answer

  3. What is the value of Scheme expression (cons 'salamander (list 'frog 'toad))

    Answer

  4. Write a Scheme function called prefix so that (prefix x y) returns #t if list x is a prefix of list y (and #f if not). It is not necessary for x to be a proper prefix of y. Every list is a prefix of itself, and the empty list is a prefix of every list. Be careful to use Scheme syntax correctly.

    Answer

  5. Write a Scheme function called descending so that (descending L) is true for a list of numbers L if L is in descending order. (The Scheme function < does a less-than test, and > does a greater-than test.) List (a b c d) is in descending order if a > b > c > d. The empty list is in descending order by definition, as is a singleton list. Be careful to use Scheme syntax correctly.

    Answer

  6. Write a Scheme function called drop so that (drop n L) returns the result of removing the first n members from list L. If L has fewer than n members, then (drop n L) should return the empty list. For example, (drop 2 '(4 8 3 5 7)) = (3 5 7) and (drop 3 '(5 2)) = ( ). Be careful to use Scheme syntax correctly.

    Answer

  7. Write a Scheme function (filter fL) that returns a list of all members x of list L such that (fx) is not #f. (Notice that f  is a function.) Be careful to use Scheme syntax correctly.

    Answer