;;;
-;;; $Id: tl-list.el,v 0.3 1994/07/16 04:08:52 morioka Exp morioka $
+;;; $Id: tl-list.el,v 0.6 1994/08/28 17:10:12 morioka Exp $
;;;
(provide 'tl-list)
+;;; @ list
+;;;
+
+(defun last (list)
+ "Returns the last element in the list <LIST>.
+[mol's Common Lisp emulating function]"
+ (nthcdr (- (length list) 1) list)
+ )
+
+(defun butlast (x &optional n)
+ "Returns a copy of LIST with the last N elements removed.
+[tl-list.el: imported from cl.el]"
+ (if (and n (<= n 0)) x
+ (nbutlast (copy-sequence x) n)))
+
+(defun nbutlast (x &optional n)
+ "Modifies LIST to remove the last N elements.
+[tl-list.el: imported from cl.el]"
+ (let ((m (length x)))
+ (or n (setq n 1))
+ (and (< n m)
+ (progn
+ (if (> n 0) (setcdr (nthcdr (- (1- m) n) x) nil))
+ x))))
+
+
;;; @ alist
;;;
(defun put-alist (item value alist)
- "\t(put-alist <ITEM> <VALUE> <ALIST>)\n
-If there is a pair whose car is <ITEM>, replace its cdr by <VALUE>.
+ "If there is a pair whose car is <ITEM>, replace its cdr by <VALUE>.
If there is not such pair, create new pair (<ITEM> . <VALUE>) and
return new alist whose car is the new pair and cdr is <ALIST>.
[mol's ELIS emulating function]"
))
(defun del-alist (item alist)
- "\t(del-alist <ITEM> <ALIST>)\n
-If there is a pair whose key is <ITEM>, delete it from <ALIST>.
+ "If there is a pair whose key is <ITEM>, delete it from <ALIST>.
[mol's ELIS emulating function]"
(if (equal item (car (car alist)))
(cdr alist)