projects
/
kmrcl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
r8073: add def-cached-vector
[kmrcl.git]
/
lists.lisp
diff --git
a/lists.lisp
b/lists.lisp
index 285bb397f426333f8b3eac243144c8704d08eb05..35e74ba3482236cf8dd4f01cfc6948de66e273bd 100644
(file)
--- a/
lists.lisp
+++ b/
lists.lisp
@@
-7,7
+7,7
@@
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Apr 2000
;;;;
;;;; Programmer: Kevin M. Rosenberg
;;;; Date Started: Apr 2000
;;;;
-;;;; $Id
: lists.lisp,v 1.8 2003/07/05 02:32:08 kevin Exp
$
+;;;; $Id$
;;;;
;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
;;;;
;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg
;;;;
@@
-22,26
+22,33
@@
"Make into list if atom"
(if (listp obj) obj (list obj)))
"Make into list if atom"
(if (listp obj) obj (list obj)))
-(defun
filter
(fn lst)
- "
Filter
a list by function, eliminate elements where fn returns nil"
+(defun
map-and-remove-nils
(fn lst)
+ "
mao
a list by function, eliminate elements where fn returns nil"
(let ((acc nil))
(dolist (x lst (nreverse acc))
(let ((val (funcall fn x)))
(when val (push val acc))))))
(let ((acc nil))
(dolist (x lst (nreverse acc))
(let ((val (funcall fn x)))
(when val (push val acc))))))
+(defun filter (fn lst)
+ "Filter a list by function, eliminate elements where fn returns nil"
+ (let ((acc nil))
+ (dolist (x lst (nreverse acc))
+ (when (funcall fn x)
+ (push x acc)))))
+
(defun appendnew (l1 l2)
"Append two lists, filtering out elem from second list that are already in first list"
(dolist (elem l2 l1)
(unless (find elem l1)
(setq l1 (append l1 (list elem))))))
(defun appendnew (l1 l2)
"Append two lists, filtering out elem from second list that are already in first list"
(dolist (elem l2 l1)
(unless (find elem l1)
(setq l1 (append l1 (list elem))))))
-(defun remove-tree-if (pred tree)
+(defun remove-
from-
tree-if (pred tree)
"Strip from tree of atoms that satistify predicate"
(if (atom tree)
(unless (funcall pred tree)
tree)
"Strip from tree of atoms that satistify predicate"
(if (atom tree)
(unless (funcall pred tree)
tree)
- (let ((car-strip (remove-tree-if pred (car tree)))
- (cdr-strip (remove-tree-if pred (cdr tree))))
+ (let ((car-strip (remove-
from-
tree-if pred (car tree)))
+ (cdr-strip (remove-
from-
tree-if pred (cdr tree))))
(cond
((and car-strip (atom (cadr tree)) (null cdr-strip))
(list car-strip))
(cond
((and car-strip (atom (cadr tree)) (null cdr-strip))
(list car-strip))
@@
-162,7
+169,7
@@
(defun plist-alist (plist)
(do ((alist '())
(defun plist-alist (plist)
(do ((alist '())
- (pl plist (cddr pl
ist
)))
+ (pl plist (cddr pl)))
((null pl) alist)
(setq alist (acons (car pl) (cadr pl) alist))))
((null pl) alist)
(setq alist (acons (car pl) (cadr pl) alist))))