fix: darcs merge conflict was recorded into package.lisp
[alexandria.git] / arrays.lisp
blobe2c0a3f150895746c24179720b1f1776490a6947
1 (in-package :alexandria)
3 (deftype array-index (&optional (length array-dimension-limit))
4 "Type designator for an index into array of LENGTH: an integer between
5 0 (inclusive) and LENGTH (exclusive). LENGTH defaults to
6 ARRAY-DIMENSION-LIMIT."
7 `(integer 0 (,length)))
9 (deftype array-length (&optional (length array-dimension-limit))
10 "Type designator for a dimension of an array of LENGTH: an integer between
11 0 (inclusive) and LENGTH (inclusive). LENGTH defaults to
12 ARRAY-DIMENSION-LIMIT."
13 `(integer 0 ,length))
15 (defun copy-array (array &key
16 (element-type (array-element-type array))
17 (fill-pointer (and (array-has-fill-pointer-p array)
18 (fill-pointer array)))
19 (adjustable (adjustable-array-p array)))
20 "Returns an undisplaced copy of ARRAY, with same fill-pointer
21 and adjustability (if any) as the original, unless overridden by
22 the keyword arguments."
23 (let ((dims (array-dimensions array)))
24 ;; Dictionary entry for ADJUST-ARRAY requires adjusting a
25 ;; displaced array to a non-displaced one to make a copy.
26 (adjust-array
27 (make-array dims
28 :element-type element-type :fill-pointer fill-pointer
29 :adjustable adjustable :displaced-to array)
30 dims)))