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
))))