CSC 319 Lecture 9:

Reading: Chassell 1-3, 7, 9, 11, 17. Sethi Chapters 10

Programming environment issues

Normally, you write Lisp code in a .el file, and load it into your Emacs session by executing (load-file "file.el"). Many Emacs functions are helpful in finding online documentation on Emacs Lisp, including "apropos" and "describe-function". Invoke these interactively by typing escape-X and then typing the function name and pressing return.

Some more Lisp functions

Lambda forms

(lambda (x) (* x x)) is an example of a lambda form. It is essentially an anonymous function, usable anywhere a function name would be used.

Lisp Warmup Assignment

Write the following Lisp functions.
  1. (splice L1 L2) takes two lists, and produces a list L3 whose elements are two-element lists containing the elements of L1 and L2. For example (splice '(1 2 3) '(4 5 6)) returns ((1 4) (2 5) (3 6)).
  2. (ladd L1 L2), (lsub L1 L2), (lmult L1 L2), and (ldiv L1 L2) each take two lists, and produces a list L3 whose elements are the sums, differences, products, and divisions of elements from L1 and L2. L1 and L2 must be the same length.