>(setf x '(a b c)) (A B C) >(car x) A >(cdr x) (B C) >(null x) NIL >(listp x) T >(atom x) NIL例題2 リストを処理するなら再帰を使うのが普通
(defun length1 (x y)
(if (null x)
y
(length1 (cdr x) (+ y 1))))
(defun append1 (x y)
(if (null x)
y
(cons (car x) (append1 (cdr x) y))))
(defun last1 (x)
(if (null (cdr x))
(car x)
(last1 (cdr x))))
これらは、LISP 1.5風のプログラムだ。
... が、しかし、Common LISP は、CやPascalのようにプログラミング
することもできる。
(defun program ()
(progn
(print 'a)
(print 'b)
(print 'c)))
Emacs の .emacs に付けるおまじない
(setq load-path (append load-path
'("~/etc/emacs" "/usr/open/lib/gcl-2.2/elisp" ".")))
(autoload 'dbl "dbl" "" t)
(setq dbl-mode-hook '(lambda () (dbl-call "gcl")))