comparison lisp/ilisp/ilisp-el.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children b82b59fe008d
comparison
equal deleted inserted replaced
-1:000000000000 0:376386a54a3c
1 ;;; -*- Mode: Emacs-Lisp -*-
2
3 ;;; ilisp-el.el --
4
5 ;;; This file is part of ILISP.
6 ;;; Version: 5.7
7 ;;;
8 ;;; Copyright (C) 1990, 1991, 1992, 1993 Chris McConnell
9 ;;; 1993, 1994 Ivan Vasquez
10 ;;; 1994, 1995 Marco Antoniotti and Rick Busdiecker
11 ;;;
12 ;;; Other authors' names for which this Copyright notice also holds
13 ;;; may appear later in this file.
14 ;;;
15 ;;; Send mail to 'ilisp-request@lehman.com' to be included in the
16 ;;; ILISP mailing list. 'ilisp@lehman.com' is the general ILISP
17 ;;; mailing list were bugs and improvements are discussed.
18 ;;;
19 ;;; ILISP is freely redistributable under the terms found in the file
20 ;;; COPYING.
21
22
23 ;;;
24 ;;; ILISP extensions to emacs lisp
25 ;;;
26
27
28
29 ;;;%Utils
30 ;;; This should be in emacs, but it isn't.
31 (defun lisp-mem (item list &optional elt=)
32 "Test to see if ITEM is equal to an item in LIST.
33 Option comparison function ELT= defaults to equal."
34 (let ((elt= (or elt= (function equal)))
35 (done nil))
36 (while (and list (not done))
37 (if (funcall elt= item (car list))
38 (setq done list)
39 (setq list (cdr list))))
40 done))
41
42
43
44 ;;;%%Misc
45 (defun lisp-memk (item list key)
46 "Test to see if ITEM is in LIST using KEY on each item in LIST
47 before comparing it to ITEM."
48 (lisp-mem item list (function (lambda (x y)
49 (equal x (funcall key y))))))
50
51 ;;; This should be in emacs, but it isn't.
52 (defun lisp-del (item list &optional test)
53 "Delete ITEM from LIST using TEST comparison and return the result.
54 Default test is equal."
55 (let ((test (or test (function equal)))
56 (element list)
57 (prev nil)
58 (done nil))
59 (while (and element (not done))
60 (if (funcall test item (car element))
61 (progn
62 (setq done t)
63 (if prev
64 (rplacd prev (cdr element))
65 (setq list (cdr list))))
66 (setq prev element
67 element (cdr element))))
68 list))
69
70 ;;;
71 (defun lisp-last (list)
72 "Return the last element of LIST."
73 (while (cdr list)
74 (setq list (cdr list)))
75 (car list))