Ithaca College Logo Ithaca College Home Blue Header

Ithaca College, Ithaca, New York
*

Practicum 4

Due: Thursday, 21 February, beginning of class.


Objectives:

Reference: The Scheme Programming Language, R. Kent Dybvig, Addison-Wesley, 2003.


Requirements:


Practicum:

  1. Define a function doThree that takes three paramters f, g and h, all functions, and returns a function that takes two arguments and constructs a list that contains the results of applying f, g and h to those arguments. Test your function on:
  1. Define a function mapToThree that takes four parameters, f, g, lst1, and lst2 and maps the two lists to the two parameters. The result returned must be a single list. In the list should be the result of applying f to the first item of lst1 and the first item of lst2, then the result of applying g to the first item of lst1 and the first item of lst2, then the result of applying f to the second item of lst1 and the second item of lst2, then the result of applying g to the second item of lst1 and the second item of lst2, etc. Test your function on:
  2. > (mapToThree + * '(1 2 3) '(4 5 6))
    (5 4 7 10 9 18)
    > (mapToThree cons list '(a b c) '(d e f))
    ((a . d) (a d) (b . e) (b e) (c . f) (c f))
    > (mapToThree < > '(1 10 20) '(50 30 10))
    (#t #f #t #f #f #t)
    > 
    

  1. Define a function compIt that takes three paramters, a function f an item, x, and a list, ls. The parameter must be some sort of test. compIt will use the test function, f, to compare the item to each element of the list and will return a list of all items that passed that test. Note that ls may itself contain lists that must also be tested. Test your function on:
  1. Define two functions create-expression and results. The first fucntion will take 4 parameters, two operators and two lists of numbers. You may assume that the lists are well-formed (i.e., comprised of only numbers, no embedded lists). create-expression must return an expression that applys the second operator to each list and then applies the first operator to those two results. For example, the call

    The second function results will take an expression created by create-expression and return the result of evaluating that expression. Test your function on:


Last updated on 14 Feb 2008 by John Barr