X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=tl-list.el;h=4c2a538693fa5d354675231d44ca72b79c7ef1e8;hb=3fe76b044cf6350e4fddadbc8e3c12af0a97866b;hp=93f861c0b672b26751996d7df1ebd1308abd91fb;hpb=005aa36fcd52725b175fe13376b26a9cbf8dba96;p=elisp%2Ftm.git diff --git a/tl-list.el b/tl-list.el index 93f861c..4c2a538 100644 --- a/tl-list.el +++ b/tl-list.el @@ -1,5 +1,5 @@ ;;; -;;; $Id: tl-list.el,v 1.2 1994/10/29 14:40:02 morioka Exp $ +;;; $Id: tl-list.el,v 2.5 1994/12/27 01:49:41 morioka Exp $ ;;; (provide 'tl-list) @@ -33,6 +33,27 @@ x)))) +(defun nth-prev (n ls) + "Return elements of LS until N - 1 th. [tl-list.el]" + (butlast ls (- (length ls) n)) + ) + +(defun except-nth (n ls) + "Return elements of LS except N th. [tl-list.el]" + (append (nth-prev n ls) (nthcdr (+ 1 n) ls)) + ) + +(defun last-element (ls) + "Return last element. [tl-list.el]" + (car (last ls)) + ) + + +;;; @ set +;;; +(fset 'is-member 'member) + + ;;; @ alist ;;; @@ -79,11 +100,30 @@ return new alist whose car is the new pair and cdr is . ;;; (defun fetch-field (key alist) - (assoc key alist)) + (assoc key alist) + ) + +(defun fetch-field-value (key alist) + (cdr (assoc key alist)) + ) (fset 'put-field 'put-alist) (fset 'delete-field 'del-alist) +(defun put-fields (tp c) + (catch 'tag + (let ((r tp) f ret) + (while r + (setq f (car r)) + (if (not (if (setq ret (fetch-field (car f) c)) + (equal (cdr ret)(cdr f)) + (setq c (cons f c)) + )) + (throw 'tag 'error)) + (setq r (cdr r)) + )) + c)) + ;;; @ field unifier ;;; @@ -165,3 +205,21 @@ return new alist whose car is the new pair and cdr is . ) (list prev (append cla ins) rest) ))) + +(defun get-unified-alist (db al) + (let ((r db) ret) + (catch 'tag + (while r + (if (setq ret (nth 1 (assoc-unify (car r) al))) + (throw 'tag ret) + ) + (setq r (cdr r)) + )))) + +(defun set-atype (sym al) + (if (null (boundp sym)) + (set sym al) + (let ((ret (get-unified-alist (eval sym) al))) + (if (not (equal ret al)) + (set sym (cons al (eval sym))) + ))))