X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=lists.lisp;h=229bc91d6cc40d73bece0377d419db1d56a83ee4;hb=e2450e52a0813b8583395d7ac88f24e896f46e13;hp=bc2866498e00e67ef9cd8c509aa634c81a034028;hpb=d11d6cc43fd9227a8aeed28dc2cfecdbc587ec4a;p=kmrcl.git diff --git a/lists.lisp b/lists.lisp index bc28664..229bc91 100644 --- a/lists.lisp +++ b/lists.lisp @@ -42,13 +42,15 @@ (unless (find elem l1) (setq l1 (append l1 (list elem)))))) -(defun remove-from-tree-if (pred tree) +(defun remove-from-tree-if (pred tree &optional atom-processor) "Strip from tree of atoms that satistify predicate" (if (atom tree) (unless (funcall pred tree) - tree) - (let ((car-strip (remove-from-tree-if pred (car tree))) - (cdr-strip (remove-from-tree-if pred (cdr tree)))) + (if atom-processor + (funcall atom-processor tree) + tree)) + (let ((car-strip (remove-from-tree-if pred (car tree) atom-processor)) + (cdr-strip (remove-from-tree-if pred (cdr tree) atom-processor))) (cond ((and car-strip (atom (cadr tree)) (null cdr-strip)) (list car-strip)) @@ -169,7 +171,7 @@ (defun plist-alist (plist) (do ((alist '()) - (pl plist (cddr plist))) + (pl plist (cddr pl))) ((null pl) alist) (setq alist (acons (car pl) (cadr pl) alist))))