Assignment 3 for CSCI 431

Running Scheme at UNCA

MIT Scheme is installed on Burnsville which is located in 006. You can invoke the Scheme interpreter by giving the command scheme at the UNIX prompt when logged on to Burnsville. To leave the Scheme interpreter give the command (exit).

Exercises

  1. Expressions
    Draw the box-and-point structure (the CONS cells and pointers) for the following expressions:
    1. (((a (b)) c) d)
    2. (a (b c) d e)

  2. Programming:
    Define the following functions using the Scheme primitive functions that have been introduced in class (e.g. CAR, CDR, CONS, COND, LIST, LIST?, EQ?, EQUAL? etc.)
    1. Define a procedue index that has two arguments, an item a and a list of items ls, and returns the index of a in ls. That is, the zero-based location of a in ls. If the item is not in the list, the procedure returns -1. For example:
      • (index 3 '(1 2 3 4 5 6 7)) ==> 2
      • (index 'so '(do re me fa so ka tu do)) ==> 4
      • (index 'a '(b c d e)) ==> -1
    2. Write a recursive procedure length-it that computes the length of any given list.