Skip to content
Snippets Groups Projects
Commit 5cb8cc56 authored by gerd's avatar gerd
Browse files

NTHCDR and NTH are specified to accept unsigned-byte.

	Found by Paul Dietz, fixed by Alexey Dejneka in SBCL.

	* src/compiler/fndb.lisp (nth, nthcdr): First arg is
	unsigned-byte.

	* src/code/list.lisp (nthcdr): Cope with bignums.
parent 21ee6424
No related branches found
No related tags found
No related merge requests found
......@@ -5,7 +5,7 @@
;;; Carnegie Mellon University, and has been placed in the public domain.
;;;
(ext:file-comment
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/list.lisp,v 1.31 2003/05/26 20:20:32 gerd Exp $")
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/code/list.lisp,v 1.32 2003/07/01 15:04:09 gerd Exp $")
;;;
;;; **********************************************************************
;;;
......@@ -173,12 +173,21 @@
(cdr list))
(defun nthcdr (n list)
(declare (type index n))
"Performs the cdr function n times on a list."
(do ((i n (1- i))
(result list (cdr result)))
((not (plusp i)) result)
(declare (type index i))))
(flet ((fast-nthcdr (n list)
(declare (type index n))
(do ((i n (1- i))
(result list (cdr result)))
((not (plusp i)) result)
(declare (type index i)))))
(typecase n
(index (fast-nthcdr n list))
(t (do ((i 0 (1+ i))
(r-i list (cdr r-i))
(r-2i list (cddr r-2i)))
((and (eq r-i r-2i) (not (zerop i)))
(fast-nthcdr (mod n i) r-i))
(declare (type index i)))))))
(defun last (list &optional (n 1))
"Returns the last N conses (not the last element!) of a list."
......
......@@ -5,7 +5,7 @@
;;; Carnegie Mellon University, and has been placed in the public domain.
;;;
(ext:file-comment
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/fndb.lisp,v 1.115 2003/06/06 16:23:46 toy Exp $")
"$Header: /Volumes/share2/src/cmucl/cvs2git/cvsroot/src/compiler/fndb.lisp,v 1.116 2003/07/01 15:04:09 gerd Exp $")
;;;
;;; **********************************************************************
;;;
......@@ -596,7 +596,7 @@
(foldable flushable call))
(defknown endp (list) boolean (foldable flushable movable))
(defknown list-length (list) (or index null) (foldable flushable))
(defknown (nth nthcdr) (index list) t (foldable flushable))
(defknown (nth nthcdr) (unsigned-byte list) t (foldable flushable))
(defknown last (list &optional index) list (foldable flushable))
(defknown list (&rest t) list (movable flushable unsafe))
(defknown list* (t &rest t) t (movable flushable unsafe))
......
......@@ -127,6 +127,7 @@ New in this release:
- SLOT-VALUE, (SETF SLOT-VALUE), SLOT-BOUNDP, SLOT-MAKUNBOUND
returning values specified by the standard when SLOT-UNBOUND
or SLOT-MISSING are called and return.
- NTH and NTHCDR accepting bignums as first argument.
* Numerous bugfixes:
- NSET-EXCLUSIVE-OR returns the same results as SET-EXCLUSIVE-OR
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment