Date: Wed, 08 Jan 1997 21:28:59 GMT Server: NCSA/1.4.2 Content-type: text/html First Lisp Assignment



next up previous
Next: Establishing your MSCC

CS341, Spring 1996
LISP Assignment #0
Assigned 3/25, (not to hand in).



The Assignment:

  1. Set up your MSCC account (instructions here) and log on.
  2. Register yourself on the class mailing list (instructions here).
  3. Find the Course Web. Hint:
    http://www.cs.washington.edu/education/courses/341/
    
  4. Look at the tutorial on how to use the Lisp/Emacs interface on the Course Web. Follow the instructions in the Getting started section for setting up the initialization files.
  5. Start Emacs.
  6. Open a buffer for a new Lisp code file called
    program.lisp
    
    to hold the code for the first asssignment. You should notice on the Emacs status line at the bottom of the window that a lot of ``fi'' code is getting loaded into Emacs. (``Fi'' stands for ``Franz interface,'' and this is the Emacs code that manages the Lisp editor buffers and the interaction between Lisp and the editor.)

  7. Type in the simple program here. (You don't have to type in the comments if you don't want.) The main thing to notice while you're doing this is that the Emacs editor will help by indenting your code for you. Every time you hit a carriage return it will indent you on the next line. If you don't see the same indentation pattern as in the sample code, you probably have too many or two few parentheses.

  8. Although you have now written a Lisp program, you are not yet running the Lisp interpreter, so there's nobody around to appreciate your great typing job. Start a Lisp process now, as per the instructions in the Lisp/Emacs tutorial.

  9. Evaluate the program code. Instructions here; also see the tutorial. You have now defined several functions, one for each defun in the program file, but you really only want to run one of them.

  10. Run the code by typing in
    (play-one-round)
    
    (Upper or lower case, it doesn't matter.) You will get an error message. Try to figure out what is causing it.

  11. Fix the error in your editor buffer, re-load the buffer and run the function again. Have fun playing this exciting game!

  12. The format function is a built-in Lisp function that does formatted output. Try to figure out how it works. (Hint: use the Common Lisp manual to get the manual page for format. The tutorial will tell you how. We'll discuss it in class.

  13. If you're feeling bold, put all your new knowledge together and write your first Lisp program. Write a function that takes two numbers as arguments and prints their sum. It should behave something like this:
        USER(1): (print-sum 2 -7)
        The sum of 2 and -7 is -5.
        NIL
        USER(2):
    
    (The USER(1): is just a prompt from Lisp telling you it's waiting for input.)

  14. Discussion question for class: what is this NIL thing, and why do we keep seeing it??!?





next up previous
Next: Establishing your MSCC



Steve Hanks
Wed Mar 27 11:22:38 PST 1996