Changeset 275


Ignore:
Timestamp:
Jan 13, 2004, 4:52:26 PM (21 years ago)
Author:
Gary Byers
Message:

Use ENDP to detect bad alists in COPY-ALIST. Move ALT-LIST-LENGTH elsewhere
(and fix it ...)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ccl/lib/lists.lisp

    r265 r275  
    128128(defun copy-alist (alist)
    129129  "Returns a new association list equal to alist, constructed in space"
    130   (if (atom alist)
    131     (if alist
    132       (report-bad-arg alist 'list))
     130  (unless (endp alist)
    133131    (let ((result
    134            (cons (if (atom (car alist))
     132           (cons (if (endp (car alist))
    135133                   (car alist)
    136134                   (cons (caar alist) (cdar alist)) )
     
    140138                   (cdr (rplacd splice
    141139                                (cons
    142                                  (if (atom (car x))
     140                                 (if (endp (car x))
    143141                                   (car x)
    144142                                   (cons (caar x) (cdar x)))
    145143                                 '() ))) ))
    146           ;;; Non-null terminated alist done here.
    147           ((atom x) (unless (null x)
    148                       (rplacd splice x))
    149            result)))))
     144          ((endp x) result)))))
    150145
    151146;;; More Commonly-used List Functions
     
    156151
    157152
    158 (defun alt-list-length (l)
    159   "Detect (and complain about) cirucular lists; allow any atom to
    160 terminate the list"
    161   (do* ((n 0 (1+ n))
    162         (fast l)
    163         (slow l))
    164        ((atom fast) (if fast (the fixnum (1+ n)) n))
    165     (declare (fixnum n))
    166     (setq fast (cdr fast))
    167     (if (logbitp 0 n)
    168       (if (eq (setq slow (cdr slow)) fast)
    169         (%err-disp $XIMPROPERLIST l)))))
     153
    170154
    171155(defun butlast (list &optional (n 1 n-p))
Note: See TracChangeset for help on using the changeset viewer.