2 ;;; $Id: tl-list.el,v 0.6 1994/08/28 17:10:12 morioka Exp $
11 "Returns the last element in the list <LIST>.
12 [mol's Common Lisp emulating function]"
13 (nthcdr (- (length list) 1) list)
16 (defun butlast (x &optional n)
17 "Returns a copy of LIST with the last N elements removed.
18 [tl-list.el: imported from cl.el]"
19 (if (and n (<= n 0)) x
20 (nbutlast (copy-sequence x) n)))
22 (defun nbutlast (x &optional n)
23 "Modifies LIST to remove the last N elements.
24 [tl-list.el: imported from cl.el]"
29 (if (> n 0) (setcdr (nthcdr (- (1- m) n) x) nil))
36 (defun put-alist (item value alist)
37 "If there is a pair whose car is <ITEM>, replace its cdr by <VALUE>.
38 If there is not such pair, create new pair (<ITEM> . <VALUE>) and
39 return new alist whose car is the new pair and cdr is <ALIST>.
40 [mol's ELIS emulating function]"
41 (if (assoc item alist)
43 (rplacd (assoc item alist) value)
45 (cons (cons item value) alist)
48 (defun del-alist (item alist)
49 "If there is a pair whose key is <ITEM>, delete it from <ALIST>.
50 [mol's ELIS emulating function]"
51 (if (equal item (car (car alist)))
58 (if (equal item (car (car r)))
71 (defun fetch-field (key alist)
74 (fset 'put-field 'put-alist)
75 (fset 'delete-field 'del-alist)