Fix default ARRAY-INDEX and ARRAY-LENGTH.
[alexandria.git] / arrays.lisp
blob76c18791ad5f416acafb9a119b401329b9dbf78e
1 (in-package :alexandria)
3 (defun copy-array (array &key (element-type (array-element-type array))
4 (fill-pointer (and (array-has-fill-pointer-p array)
5 (fill-pointer array)))
6 (adjustable (adjustable-array-p array)))
7 "Returns an undisplaced copy of ARRAY, with same fill-pointer and
8 adjustability (if any) as the original, unless overridden by the keyword
9 arguments."
10 (let* ((dimensions (array-dimensions array))
11 (new-array (make-array dimensions
12 :element-type element-type
13 :adjustable adjustable
14 :fill-pointer fill-pointer)))
15 (dotimes (i (array-total-size array))
16 (setf (row-major-aref new-array i)
17 (row-major-aref array i)))
18 new-array))