2 ;;; lists.cl -- various lisp list utilities that make my life easier
4 ;;; Author: Cyrus Harmon <ch-lisp@bobobeach.com>
9 ;;; Miscellaneous list utilities
11 (defun insert-before (new old list
)
12 (labels ((build-list (old c
&optional newlist
)
15 (append (reverse (cdr c
)) (cons (car c
) (cons new newlist
)))
16 (build-list old
(cdr c
) (cons (car c
) newlist
)))
18 (reverse (build-list old list
))))
20 (defun insert-before-all (new old list
)
21 (labels ((build-list (old c
&optional newlist
)
24 (build-list old
(cdr c
) (cons (car c
) (cons new newlist
)))
25 (build-list old
(cdr c
) (cons (car c
) newlist
)))
27 (reverse (build-list old list
))))
36 (defun properties (plist)
37 "Returns a list of the names properties present in plist, but
38 not the value of the properties."
39 (loop for prop in plist by
#'cddr collect prop
))
41 (defun remove-nulls (list)
42 (loop for l in list append
(when l
(list l
))))
44 (defun ensure-list (l)