X-Git-Url: http://git.kpe.io/?a=blobdiff_plain;f=lists.lisp;h=ecdd003f993ec85dd20ee160f23017cb0c2eefb3;hb=d98ff150815e427ae475303fbd09e734cb345cb7;hp=b51c41a5072c396e1bf0a3f7ead8d292d14226be;hpb=03712fbb06acbb103602bae10f41aeae7fa05127;p=kmrcl.git diff --git a/lists.lisp b/lists.lisp index b51c41a..ecdd003 100644 --- a/lists.lisp +++ b/lists.lisp @@ -7,8 +7,6 @@ ;;;; Programmer: Kevin M. Rosenberg ;;;; Date Started: Apr 2000 ;;;; -;;;; $Id$ -;;;; ;;;; This file, part of KMRCL, is Copyright (c) 2002 by Kevin M. Rosenberg ;;;; ;;;; KMRCL users are granted the rights to distribute and use this software @@ -73,14 +71,19 @@ it nil))))) -(defun flatten (lis) - (cond ((atom lis) lis) - ((listp (car lis)) - (append (flatten (car lis)) (flatten (cdr lis)))) - (t (append (list (car lis)) (flatten (cdr lis)))))) +(defun flatten (tree) + (let ((result '())) + (labels ((scan (item) + (if (consp item) + (map nil #'scan item) + (push item result)))) + (scan tree)) + (nreverse result))) ;;; Keyword functions +;; ECL doesn't allow FOR clauses after UNTIL. +#-ecl (defun remove-keyword (key arglist) (loop for sublist = arglist then rest until (null sublist) for (elt arg . rest) = sublist