Assignment 10 for CSCI 431

Running Lisp at UNCA

CLISP is installed on the alpha's. You can invoke the clisp interpreter by giving the command clisp at the UNIX prompt. To leave the clisp interpreter give the command (quit). Other commands can be found in the on-line manual.

Exercises

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

  2. Lisp Programming:
    Define the following functions using the LISP primitive functions that have been introduced in class (e.g. FIRST, REST, CONS, COND, NULL, LIST, LISTP, ATOM, 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.