From 51c98fd08772d76c42f7c8d7d09ab628f5716ce9 Mon Sep 17 00:00:00 2001 From: Juan Jose Garcia Ripoll Date: Sat, 7 Mar 2009 11:51:44 +0100 Subject: [PATCH] FILL reimplemented using FILL-ARRAY-WITH-ELT. --- src/lsp/seqlib.lsp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/lsp/seqlib.lsp b/src/lsp/seqlib.lsp index b09f6a518..494f5018a 100644 --- a/src/lsp/seqlib.lsp +++ b/src/lsp/seqlib.lsp @@ -121,11 +121,16 @@ (decf end)))))))) (defun fill (sequence item &key (start 0) end) + ;; INV: WITH-START-END checks the sequence type and size. (with-start-end start end sequence - (do ((i start (1+ i))) - ((>= i end) sequence) - (declare (fixnum i)) - (setf (elt sequence i) item)))) + (if (listp sequence) + (do* ((x (nthcdr start sequence) (cdr x)) + (i (- end start) (1- i))) + ((zerop i) + sequence) + (declare (fixnum i) (cons x)) + (setf (first x) item)) + (si::fill-array-with-elt sequence item start end)))) (defun replace (sequence1 sequence2 &key (start1 0) end1 (start2 0) end2) (with-start-end start1 end1 sequence1