CSCI 330 Lab 1: Lisp fundamentals

Caution/warning: don't do the git fork/clone steps until Dave announces that the git repo is posted and ready.

In this lab you will create and submit lisp code that runs under steel bank common lisp (sbcl) on the cubs/pups/tux, with an emphasis on typical lisp type checking, control flow, parameter passing, i/o, recursion, and lists. The goal is to gain basic familiarity with lisp syntax and structure, then we'll rapidly get into more interesting features and functionality in future labs.

You'll have two weeks to do the lab (including the lab sessions on Jan. 12th and 19th) and it will be due at the end of the day on Jan. 25th.

The exercise involves forking/cloning a git repository, editing the lab1.cl and test1.cl files, and then submitting your updated repository.

Instructions are given below and will be discussed in the lab sessions, along with a basic intro to working with lisp/sbcl.

In this first lab we include a review of the basic git process for obtaining/submitting labs, for later labs we'll simply dive straight into the actual lab requirements.

Marking: the lab will be marked out of 18. Of that, 14 marks are for the function implementations in lab1.cl and the other 4 are for your testing of those functions in test1.cl.


Git submission system

For this lab (and all CSCI 330 labs this term) you will be using an adaptation of the git version control system to get the starting lab material, to track changes as you make them, and ultimately to submit your completed lab.

You must use this system to obtain and submit your work - no other submission mechanism will be accepted.

NOTE: if you have taken csci330 previously then it would be advisable to archive your old csci330 directory at the start of the term, e.g.
mv csci330 old330

The basic instructions to obtain your lab1 are shown below (issued from cubs/pups).

    mkdir -p csci330
    ssh csci fork csci330/lab1 csci330/$USER/lab1
    cd csci330
    git clone csci:csci330/$USER/lab1
    cd lab1

Working on and submitting your lab

After your git fork/clone steps, in your lab1 directory you should find files named lab1.cl and test1.cl, which will be the files you are ultimately graded on for the lab.

Edit the files with whatever text editor you prefer, and whenever you are ready to submit the lab use the following commands (from within your lab1 repository):
   git add lab1.cl
   git add test1.cl
   git commit -m "whatever your message is"
   git push
(You can do the add/commit/push cycle as often as desired when submitting the lab.)


Lab 1 objectives

Lab 1 is meant to give you practice with the fundamentals of programming in lisp:


Lab 1 requirements

For lab 1, you are to finish implementing the functions in the provided lab1.cl file, and test/debug them using your test1.cl script. (When I mark your lab1.cl code I'll be using my own test1.cl script as well as yours.)

The functions themselves are discussed in detail in the lab1.cl file (copied below), but in general they involve

Restrictions

With respect to the lab1.cl file and its functions, you must follow these additional restrictions (mostly aimed at enforcing a pure-ish functional approach and enforcing the use of test1.cl for testing/debugging):

lab1.cl: the key functions you are to implement

Skeletal versions of the functions have been set up in the lab1.cl file, you'll be completing the bodies of each of the functions (at the moment they each simply return nil).

Do not alter the names of the functions or their parameter lists.

The specifications for the functions are provided in the comments in lab1.cl, and are repeated below (along with description strings for each).


DETAILS TBA

Additional tips:

test1.cl: a test script for checking/debugging your functions

The test1.cl script is executable. It loads the lab1.cl file and interacts with the user to carry out any desired testing.

Its intended use is as a testing (and debugging) mechanism for you to check that your lab1.cl functions actually work correctly. All testing and debugging code, including test values, belongs in the test1.cl script, NOT in lab1.cl. Marks will be deducted if you including testing/debugging content in your lab1.cl file.

A few sample data values and test calls are included in the initial version of test1.cl, but these are nowhere near complete. A copy of the initial test file is shown below.
#! /usr/bin/sbcl --script

(format t "~%--- Begin loading lab1.cl ---~%")
(load "lab1.cl")
(format t "~%--- completed loading of lab1.cl ---~%")

DETAILS TBA

Sample working self-test run

The example below shows a run of the initial test1.cl but where the functions in lab1.cl been completed:

--- Begin loading lab1.cl --- 
 
--- completed loading of lab1.cl --- 
 
DETAILS TBA

---END OF TESTING--- 

Hints/tips for the lab1.cl functions

You're definitely not required to use these approaches, but if you're struggling with any of the functions here are the approaches I used to try and meet our functionally pure(ish) goals.

If you'd like to use this as your approach I suggest sketching a quick graph of which functions call which (and which ones recurse), as that will definitely help clarify the structure of what's going on. (It's easy to get a bit muddled just reading through the functions individually.)


DETAILS TBA