Menu

Class 2: Scheming


Reading
Section 6 of the R5 Scheme standard. It describes the builtin procedures. You don't need to read this word for word, but at least skim it to see what's there.

Homework
Write the following functions, and turn in a screen capture of the function definitions and test expressions in Dr. Scheme.
  1. Typically in Scheme predicates (i.e. functions that return true #t or false #f) have names that end in a "?". Define a predicate (modequiv? x y m) that takes three integers x, y and m and returns #t if x modulo m is equal to y modulo m. For example:
    > (modequiv? 23 21 8)
    #f
    > (modequiv? 23 31 8)
    #t
  2. Define a function (closer a b x) that returns a if a is closer to x than b is, and returns b otherwise. For example:
    > (closer 10 23 19)
    23
    > (closer 10 33 19)
    10

Continuing with Scheme basics
Today we'll continue with Lab 1. That means covering conditionals, functions and a limited form of local variable.


Christopher W Brown
Last modified: Tue Jan 10 11:28:13 EST 2006