Introduction to the Lab Environment and Common Lisp

Laboratory Exercise 1


810:161

Artificial Intelligence Laboratory


[ Goals | Background | Pre-Lab | In-Lab | Post-Lab | More Info ]

Goals for the Laboratory Exercise

The goal of this lab is to introduce you to the tools you will be using this semester. You will begin to become acquainted with your Common Lisp environment and whatever development environment you choose. You will reacquaint yourselves with the World Wide Web and with Unix mail. A secondary goal of the lab is to introduce the format of the sessions and exercises for this laboratory.


Background

We will use a common format for each of our sessions this semester and for each of the exercises you do, one per session.

Session Format

Each week's lab will work something like this:

Document Format

All of the exercises that you perform in this laboratory will be presented in the same format as this one. Each document consists of five sections, with an optional sixth.

Using E-Mail and Computing Resources

We will do much of our communication for the lab by World Wide Web and by e-mail this semester. If you would like to send your mail from one of our Linux stations but have never used mail on a Unix system before, see the CNS Unix User Guide.

Whenever you send me an e-mail message, but especially when you are submitting an assignment via e-mail, be sure to...


Pre-Lab Activities

Prior to doing the in-lab activity, be sure that you have done the following:

  1. Read this document in its entirety.
  2. Read Chapters 1-2 in ANSI Common Lisp.
  3. Access your account on cowboy. See me if you don't have one.


In-Lab Activities

Start up your Common Lisp environment. If you are working on your own machine or on another machine outside of CNS, then I won't be able to tell you exactly what to do. I might be able to answer your questions, though.

If you are working on one of the Linux boxes in CNS, especially in Wright Hall, then I can help you get started. If you have never used the work stations in this lab before, ask me for some help getting started. You should plan to spend some extra time in the lab during the first week becoming familiar with Linux, its windowing system, a mail tool, and an editor.

Whenever you are instructed to "enter" something below, type the text indicated and hit the Return key. If the indicated text is ever inside quotation marks, do not type the quotes themselves.

  1. Describe what happens when each of the following expressions is evaluated. Record the results each as a part of your answer.

  2. What does this function do?
         (defun enigma (x)
            (and (not (null x))
                 (or (null (car x))
                     (enigma (cdr x)))
            ))
    

  3. What could occur in place of the X in each of the following exchanges?
         > (car (X (cdr '(a (b c) d))))
         B
         > (X 13 (/ 1 0))
         13
    

  4. Use car and cdr to define a function that returns the fourth element in a list. Assume that the list has at least four elements.

  5. Extend your function from Problem 4 so that it works for lists with fewer than four elements.

In-Lab Deliverables

By 4:00 PM on the due date, submit:


Post-Lab Exercise

Play some more with Lisp. Feel free to read ahead in the textbook and to study its code examples in more detail. I'd especially recommend that you spend some time in front of your Lisp interpreter while studying the text. You can't read a book on a programming language the way you read a novel!

Identify:

This exercise is serious. I've been programming in Common Lisp for a long, long time, and I still have real questions about the language. I expect that all of you learning the language have real questions about the language, too. Likewise, I've haven't told you much about gcl as an interpreter, so I expect that all of you learning it for the first time have real questions about what you can and can't do with it.

Send me your questions via e-mail by 4:00 PM on the due date.


Further Information

As mentioned in the syllabus, there are a number of Lisp and Common Lisp references available to you, on reserve at the library and through me. Go over to the library and peruse these books. You'll find it useful to become familiar with these books so that, when questions arise later, you can find answers promptly.

Many Common Lisp systems provide help Common Lisp functions and features as they are implemented in the system. For example, gcl offers full on-line documentation of all built-in functions, macros, variables, constants, types, and special forms via its help facility:

(help any-symbol)

Find out what your environment others.


Eugene Wallingford ==== wallingf@cs.uni.edu ==== August 29, 2001