My lisp proogram gives me a stack overflow. How can I prevent this from happening?

Some people have run into a problem that gcl throws a stack overflow error after too many function invocations. The stack size can be increased by typing

	(setq si::*multiply-stacks* 4)
which increases the stack size by a factor of 4. If this is not sufficient, you can use a larger increase factor than 4. If this doesn't solve your problem, you may have infinite recursion in one of your functions.

What lisp system functions/macros/constructs are we allowed to use in our programs?

Unless otherwise stated, you are only allowed to use the constructs shown in the list below.
+, -, *, /, =, <=, >=, abs, and, append, atom, bye,
car, cdr, caar, cadr, cdar... etc.,
cond, cons, defun, dribble, equal, exp,
first, second, third, fourth, fifth... etc.,
last, length, let, list, listp, load, max, member, min, nil, not,
nth, null, numberp, or, remove, reverse, time.

How do I run Lisp from SEASnet?

Log in to a SEASnet UNIX machine. And type gcl (for GNU Common LISP). For gcl to work you have to add:
       setenv PATH /u/cs/class/cs161/cbin:$PATH
to your path (one way is to place the line in your .login file). If you wish to run scheme just type scheme.

How do I load a program?

Programs in LISP are just text files (usually with the .lsp extension). For short programs you may find it easiest to cut and past function definitions from your text editor into the LISP interpreter. As you programs grow you may want to have the interpreter read all your programs in automatically. To do this type (load "filename"). The result is the same as if you were to type the entire file in by hand.

How do I capture the output from GCL into a file?

The easiest way is probably to run GCL from within emacs. In emacs type M-x shell This will create a unix shell. In the unix shell start GCL. Everything will remain in the emacs buffer which can be saved like any other document (CONTROL-x CONTROL-s).

An even easier way has been suggested to me by a very astute member of the class. From the UNIX prompt type script. Then start GCL and run your program as you normally would. When you finish exit GCL, and then from the UNIX prompt type exit (or press CONTROL-d). The transcript should be in a text file called typescript.

How do I exit GCL?

You can either type (bye) or press CONTROL-d.

Aaak, GCL and submit don't work, what do I do?

If GCL and SEASNet submit don't work it is probably becuse you haven't been added to the class group by SEAS. I will be implementing a short term solution for running GCL (it should work now). You may submit your program via email by typing mail cs161ta@seas.ucla.edu < filename

Can I use loop constructs to implement my search algorithms?

No way! Don't even think about. Anything you can do in a loop you can and should do with recursion.

In a cond statement, how do you attach more than one consequent to a predicate? What I want is something like:

(cond
    (pred) (body)
       :        :
    (pred) ( (do this) & then (do that) )
)
You do it as follows.

	(cond
			((pred) (body))
			  :     :
			('t	(body1) (body2) (body3) .... )
	)