Lecture 21 – November 7, 2006

 

Filled out surveys

Got back Pascal/Lisp and Snobol re-dos from exam (max 20 points)

 

Played with Lisp.

HW Assignment: Part A

 Write a lisp function to build a list of atoms ordered in descending order.

Your function may use auxiliary functions.

Your function should insert an atom in its proper place in a list of atoms

 

Here are 3 different user-defined insert functions & a user-defined makeEmpty function:

In each case,

the top line shows the function name and parameter list and

the second line shows the return value.

 

 (defun InsertB (atom listin)

 (cons atom listin))

 

 (defun InsertA (list1 list2)

(append list1 list2) )

 

 (defun InsertC (item thelist)

                        (append (list item) thelist))

 

 (defun makeEmpty ()

'())

 

Here’s how to store a value in a variable

 (setq A (makeEmpty))

 

Here are some examples of how to test for emptiness

> (EQ NIL '(A B C))

NIL

> 

(NULL '())

T

> (NULL '(A B C))

NIL

 

Try to finish your BuildList for integers by tomorrow (Wednesday night) and put it in the drop box.  At midnight, I will post a solution. 

HW Assignment Part B:
    EITHER Build a list which represents a binary tree where each subtree is a binary list OR

   Traverse a list representing a binary tree which each subtree is a binary list.

Bring solution to class on Thursday.