Changeset 265


Ignore:
Timestamp:
Jan 11, 2004, 11:30:46 PM (21 years ago)
Author:
Gary Byers
Message:

BUTLAST, NBUTLAST handle dotted lists again.

File:
1 edited

Legend:

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

    r248 r265  
    156156
    157157
     158(defun alt-list-length (l)
     159  "Detect (and complain about) cirucular lists; allow any atom to
     160terminate 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)))))
     170
    158171(defun butlast (list &optional (n 1 n-p))
    159172  "Returns a new list the same as List without the N last elements."
     
    164177               (not (typep n 'unsigned-byte))))
    165178    (report-bad-arg n 'unsigned-byte))
    166   (let* ((length (length list)))
     179  (let* ((length (alt-list-length list)))
    167180    (declare (fixnum length))           ;guaranteed
    168181    (when (< n length)
     
    184197               (not (typep n 'unsigned-byte))))
    185198    (report-bad-arg n 'unsigned-byte))
    186   (let* ((length (length list)))
     199  (let* ((length (alt-list-length list)))
    187200    (declare (fixnum length))           ;guaranteed
    188201    (when (< n length)
Note: See TracChangeset for help on using the changeset viewer.