~ubuntu-branches/ubuntu/quantal/gclcvs/quantal

« back to all changes in this revision

Viewing changes to info/chap-15.texi

  • Committer: Bazaar Package Importer
  • Author(s): Camm Maguire
  • Date: 2004-06-24 15:13:46 UTC
  • Revision ID: james.westby@ubuntu.com-20040624151346-xh0xaaktyyp7aorc
Tags: 2.7.0-26
C_GC_OFFSET is 2 on m68k-linux

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
 
 
3
@node Arrays, Strings, Conses, Top
 
4
@chapter Arrays
 
5
 
 
6
@menu
 
7
* Array Concepts::              
 
8
* Arrays Dictionary::           
 
9
@end menu
 
10
 
 
11
@node Array Concepts, Arrays Dictionary, Arrays, Arrays
 
12
@section Array Concepts
 
13
 
 
14
@c including concept-arrays
 
15
 
 
16
@menu
 
17
* Array Elements::              
 
18
* Specialized Arrays::          
 
19
@end menu
 
20
 
 
21
@node Array Elements, Specialized Arrays, Array Concepts, Array Concepts
 
22
@subsection Array Elements
 
23
 
 
24
An @i{array} contains a set of @i{objects} called @i{elements}
 
25
that can be referenced individually according to a rectilinear coordinate system.
 
26
 
 
27
@menu
 
28
* Array Indices::               
 
29
* Array Dimensions::            
 
30
* Implementation Limits on Individual Array Dimensions::  
 
31
* Array Rank::                  
 
32
* Vectors::                     
 
33
* Fill Pointers::               
 
34
* Multidimensional Arrays::     
 
35
* Storage Layout for Multidimensional Arrays::  
 
36
* Implementation Limits on Array Rank::  
 
37
@end menu
 
38
 
 
39
@node Array Indices, Array Dimensions, Array Elements, Array Elements
 
40
@subsubsection Array Indices
 
41
 
 
42
An @i{array} @i{element} is referred to by a (possibly empty) series of indices.
 
43
The length of the series must equal the @i{rank} of the @i{array}.
 
44
 
 
45
Each index must be a non-negative @i{fixnum} 
 
46
 
 
47
less than the corresponding @i{array} @i{dimension}.
 
48
@i{Array} indexing is zero-origin.
 
49
 
 
50
@node Array Dimensions, Implementation Limits on Individual Array Dimensions, Array Indices, Array Elements
 
51
@subsubsection Array Dimensions
 
52
 
 
53
An axis of an @i{array} is called a @i{dimension}
 
54
@IGindex{dimension}
 
55
.
 
56
 
 
57
Each @i{dimension} is a non-negative 
 
58
 
 
59
@i{fixnum};
 
60
 
 
61
 if any dimension of an @i{array} is zero, the @i{array} has no elements.
 
62
It is permissible for a @i{dimension} to be zero, 
 
63
in which case the @i{array} has no elements, 
 
64
and any attempt to @i{access} an @i{element}
 
65
is an error.  However, other properties of the @i{array},  
 
66
such as the @i{dimensions} themselves, may be used.
 
67
 
 
68
@node Implementation Limits on Individual Array Dimensions, Array Rank, Array Dimensions, Array Elements
 
69
@subsubsection Implementation Limits on Individual Array Dimensions
 
70
 
 
71
An @i{implementation} may impose a limit on @i{dimensions} of an @i{array},
 
72
but there is a minimum requirement on that limit.  See the @i{variable} @b{array-dimension-limit}.
 
73
 
 
74
@node Array Rank, Vectors, Implementation Limits on Individual Array Dimensions, Array Elements
 
75
@subsubsection Array Rank
 
76
 
 
77
An @i{array} can have any number of @i{dimensions} (including zero).
 
78
The number of @i{dimensions} is called the @i{rank}
 
79
@IGindex{rank}
 
80
.
 
81
 
 
82
If the rank of an @i{array} is zero then the @i{array} is said to have
 
83
no @i{dimensions}, and the product of the dimensions (see @b{array-total-size})
 
84
is then 1; a zero-rank @i{array} therefore has a single element.
 
85
 
 
86
@node Vectors, Fill Pointers, Array Rank, Array Elements
 
87
@subsubsection Vectors
 
88
 
 
89
An @i{array} of @i{rank} one (@i{i.e.}, a one-dimensional @i{array})
 
90
is called a @i{vector}
 
91
@IGindex{vector}
 
92
.
 
93
 
 
94
@node Fill Pointers, Multidimensional Arrays, Vectors, Array Elements
 
95
@subsubsection Fill Pointers
 
96
 
 
97
A @i{fill pointer}
 
98
@IGindex{fill pointer}
 
99
 is a non-negative @i{integer} no
 
100
larger than the total number of @i{elements} in a @i{vector}.
 
101
Not all @i{vectors} have @i{fill pointers}.
 
102
See the @i{functions} @b{make-array} and @b{adjust-array}.
 
103
 
 
104
An @i{element} of a @i{vector} is said to be @i{active}
 
105
@IGindex{active}
 
106
 if it has
 
107
an index that is greater than or equal to zero, 
 
108
but less than the @i{fill pointer} (if any).
 
109
For an @i{array} that has no @i{fill pointer},
 
110
all @i{elements} are considered @i{active}.
 
111
 
 
112
Only @i{vectors} may have @i{fill pointers}; 
 
113
multidimensional @i{arrays} may not.
 
114
A multidimensional @i{array} that is displaced to a @i{vector} 
 
115
that has a @i{fill pointer} can be created.
 
116
 
 
117
@node Multidimensional Arrays, Storage Layout for Multidimensional Arrays, Fill Pointers, Array Elements
 
118
@subsubsection Multidimensional Arrays
 
119
 
 
120
@node Storage Layout for Multidimensional Arrays, Implementation Limits on Array Rank, Multidimensional Arrays, Array Elements
 
121
@subsubsection Storage Layout for Multidimensional Arrays
 
122
 
 
123
Multidimensional @i{arrays} store their components in row-major order;
 
124
that is, internally a multidimensional @i{array} is stored as a
 
125
one-dimensional @i{array}, with the multidimensional index sets
 
126
ordered lexicographically, last index varying fastest.  
 
127
 
 
128
@node Implementation Limits on Array Rank,  , Storage Layout for Multidimensional Arrays, Array Elements
 
129
@subsubsection Implementation Limits on Array Rank
 
130
 
 
131
An @i{implementation} may impose a limit on the @i{rank} of an @i{array},
 
132
but there is a minimum requirement on that limit.  See the @i{variable} @b{array-rank-limit}.
 
133
 
 
134
@node Specialized Arrays,  , Array Elements, Array Concepts
 
135
@subsection Specialized Arrays
 
136
 
 
137
An @i{array} can be a @i{general} @i{array}, 
 
138
    meaning each @i{element} may be any @i{object},
 
139
or it may be a @i{specialized} @i{array},
 
140
    meaning that each @i{element} must be of a restricted @i{type}.
 
141
 
 
142
The phrasing ``an @i{array} @i{specialized} to @i{type} <<@i{type}>>''
 
143
is sometimes used to emphasize the @i{element type} of an @i{array}.
 
144
This phrasing is tolerated even when the <<@i{type}>> is @b{t},
 
145
even though an @i{array} @i{specialized} to @i{type} @i{t}
 
146
is a @i{general} @i{array}, not a @i{specialized} @i{array}.
 
147
 
 
148
Figure 15--1 lists some @i{defined names} that are applicable to @i{array} 
 
149
creation, @i{access}, and information operations.
 
150
 
 
151
@format
 
152
@group
 
153
@noindent
 
154
@w{ adjust-array             array-in-bounds-p      svref                       }
 
155
@w{ adjustable-array-p       array-rank             upgraded-array-element-type }
 
156
@w{ aref                     array-rank-limit       upgraded-complex-part-type  }
 
157
@w{ array-dimension          array-row-major-index  vector                      }
 
158
@w{ array-dimension-limit    array-total-size       vector-pop                  }
 
159
@w{ array-dimensions         array-total-size-limit vector-push                 }
 
160
@w{ array-element-type       fill-pointer           vector-push-extend          }
 
161
@w{ array-has-fill-pointer-p make-array                                         }
 
162
 
 
163
@noindent
 
164
@w{           Figure 15--1: General Purpose Array-Related Defined Names          }
 
165
 
 
166
@end group
 
167
@end format
 
168
 
 
169
@menu
 
170
* Array Upgrading::             
 
171
* Required Kinds of Specialized Arrays::  
 
172
@end menu
 
173
 
 
174
@node Array Upgrading, Required Kinds of Specialized Arrays, Specialized Arrays, Specialized Arrays
 
175
@subsubsection Array Upgrading
 
176
 
 
177
The @i{upgraded array element type}
 
178
@IGindex{upgraded array element type}
 
179
 of a @i{type} T_1
 
180
is a @i{type} T_2 that is a @i{supertype} of T_1
 
181
and that is used instead of T_1 whenever T_1
 
182
is used as an @i{array element type} 
 
183
for object creation or type discrimination.
 
184
 
 
185
During creation of an @i{array},
 
186
the @i{element type} that was requested 
 
187
is called the @i{expressed array element type}
 
188
@IGindex{expressed array element type}
 
189
.
 
190
The @i{upgraded array element type} of the @i{expressed array element type}
 
191
becomes the @i{actual array element type}
 
192
@IGindex{actual array element type}
 
193
 of the @i{array} that is created.
 
194
 
 
195
@i{Type} @i{upgrading} implies a movement upwards in the type hierarchy lattice.
 
196
A @i{type} is always a @i{subtype} of its @i{upgraded array element type}.
 
197
Also, if a @i{type} T_x is a @i{subtype} of another @i{type} T_y,
 
198
then
 
199
the @i{upgraded array element type} of T_x 
 
200
must be a @i{subtype} of
 
201
the @i{upgraded array element type} of T_y.
 
202
Two @i{disjoint} @i{types} can be @i{upgraded} to the same @i{type}.
 
203
 
 
204
The @i{upgraded array element type} T_2 of a @i{type} T_1
 
205
is a function only of T_1 itself;
 
206
that is, it is independent of any other property of the @i{array} 
 
207
for which T_2 will be used,
 
208
such as @i{rank}, @i{adjustability}, @i{fill pointers}, or displacement.
 
209
The @i{function} @b{upgraded-array-element-type} 
 
210
can be used by @i{conforming programs} to predict how the @i{implementation}
 
211
will @i{upgrade} a given @i{type}.
 
212
 
 
213
@node Required Kinds of Specialized Arrays,  , Array Upgrading, Specialized Arrays
 
214
@subsubsection Required Kinds of Specialized Arrays
 
215
 
 
216
@i{Vectors} whose @i{elements} are restricted to @i{type}
 
217
 
 
218
@b{character} or a @i{subtype} of @b{character}
 
219
 
 
220
are called @i{strings}
 
221
@IGindex{string}
 
222
 
223
@i{Strings} are of @i{type} @b{string}.
 
224
Figure 15--2 lists some @i{defined names} related to @i{strings}.
 
225
 
 
226
@i{Strings} are @i{specialized} @i{arrays} 
 
227
and might logically have been included in this chapter.
 
228
However, for purposes of readability
 
229
most information about @i{strings} does not appear in this chapter;
 
230
see instead @ref{Strings}.
 
231
 
 
232
@format
 
233
@group
 
234
@noindent
 
235
@w{  char                string-equal         string-upcase  }
 
236
@w{  make-string         string-greaterp      string@t{/=}       }
 
237
@w{  nstring-capitalize  string-left-trim     string@t{<}        }
 
238
@w{  nstring-downcase    string-lessp         string@t{<=}       }
 
239
@w{  nstring-upcase      string-not-equal     string@t{=}        }
 
240
@w{  schar               string-not-greaterp  string@t{>}        }
 
241
@w{  string              string-not-lessp     string@t{>=}       }
 
242
@w{  string-capitalize   string-right-trim                   }
 
243
@w{  string-downcase     string-trim                         }
 
244
 
 
245
@noindent
 
246
@w{      Figure 15--2: Operators that Manipulate Strings     }
 
247
 
 
248
@end group
 
249
@end format
 
250
 
 
251
@i{Vectors} whose @i{elements} are restricted to @i{type}
 
252
@b{bit} are called @i{bit vectors}
 
253
@IGindex{bit vector}
 
254
.
 
255
@i{Bit vectors} are of @i{type} @b{bit-vector}.
 
256
Figure 15--3 lists some @i{defined names} for operations on @i{bit arrays}.
 
257
 
 
258
@format
 
259
@group
 
260
@noindent
 
261
@w{  bit        bit-ior   bit-orc2  }
 
262
@w{  bit-and    bit-nand  bit-xor   }
 
263
@w{  bit-andc1  bit-nor   sbit      }
 
264
@w{  bit-andc2  bit-not             }
 
265
@w{  bit-eqv    bit-orc1            }
 
266
 
 
267
@noindent
 
268
@w{  Figure 15--3: Operators that Manipulate Bit Arrays}
 
269
 
 
270
@end group
 
271
@end format
 
272
 
 
273
@c end of including concept-arrays
 
274
 
 
275
@node Arrays Dictionary,  , Array Concepts, Arrays
 
276
@section Arrays Dictionary
 
277
 
 
278
@c including dict-arrays
 
279
 
 
280
@menu
 
281
* array::                       
 
282
* simple-array::                
 
283
* vector (System Class)::       
 
284
* simple-vector::               
 
285
* bit-vector::                  
 
286
* simple-bit-vector::           
 
287
* make-array::                  
 
288
* adjust-array::                
 
289
* adjustable-array-p::          
 
290
* aref::                        
 
291
* array-dimension::             
 
292
* array-dimensions::            
 
293
* array-element-type::          
 
294
* array-has-fill-pointer-p::    
 
295
* array-displacement::          
 
296
* array-in-bounds-p::           
 
297
* array-rank::                  
 
298
* array-row-major-index::       
 
299
* array-total-size::            
 
300
* arrayp::                      
 
301
* fill-pointer::                
 
302
* row-major-aref::              
 
303
* upgraded-array-element-type::  
 
304
* array-dimension-limit::       
 
305
* array-rank-limit::            
 
306
* array-total-size-limit::      
 
307
* simple-vector-p::             
 
308
* svref::                       
 
309
* vector::                      
 
310
* vector-pop::                  
 
311
* vector-push::                 
 
312
* vectorp::                     
 
313
* bit (Array)::                         
 
314
* bit-and::                     
 
315
* bit-vector-p::                
 
316
* simple-bit-vector-p::         
 
317
@end menu
 
318
 
 
319
@node array, simple-array, Arrays Dictionary, Arrays Dictionary
 
320
@subsection array                                                        [System Class]
 
321
 
 
322
@subsubheading  Class Precedence List::
 
323
@b{array},
 
324
@b{t}
 
325
 
 
326
@subsubheading  Description::
 
327
 
 
328
An @i{array} contains @i{objects} arranged according to a
 
329
Cartesian coordinate system.
 
330
An @i{array} provides mappings from a set of
 
331
 
 
332
@i{fixnums}
 
333
 
 
334
\left@{i_0,i_1,\dots,i_@{r-1@}\right@} to corresponding @i{elements}
 
335
of the @i{array}, 
 
336
where 0 \le i_j < d_j,
 
337
r is the rank of the array, and d_j is the size of @i{dimension} j of
 
338
the array.
 
339
 
 
340
When an @i{array} is created, the program requesting its creation may
 
341
declare that all @i{elements} are of a particular @i{type}, 
 
342
called the @i{expressed array element type}.
 
343
The implementation is permitted to @i{upgrade} this type in order to 
 
344
produce the @i{actual array element type},
 
345
which is the @i{element type} for the @i{array} is actually @i{specialized}.
 
346
See the @i{function} @b{upgraded-array-element-type}.
 
347
 
 
348
@subsubheading  Compound Type Specifier Kind::
 
349
 
 
350
Specializing.
 
351
 
 
352
@subsubheading  Compound Type Specifier Syntax::
 
353
 
 
354
(@code{array}@{@i{@t{[}@{element-type | @b{*}@} @r{[}dimension-spec@r{]}@t{]}}@})
 
355
 
 
356
@w{@i{dimension-spec} ::=rank | @b{*} | @r{(}@{dimension | @b{*}@}*@r{)}}
 
357
 
 
358
@subsubheading  Compound Type Specifier Arguments::
 
359
 
 
360
@i{dimension}---a @i{valid array dimension}.
 
361
 
 
362
@i{element-type}---a @i{type specifier}.
 
363
 
 
364
@i{rank}---a non-negative @i{fixnum}.
 
365
 
 
366
@subsubheading  Compound Type Specifier Description::
 
367
 
 
368
This denotes the set of @i{arrays} whose
 
369
  @i{element type},  @i{rank},  and @i{dimensions}
 
370
match any given
 
371
  @i{element-type}, @i{rank}, and @i{dimensions}.
 
372
Specifically:
 
373
 
 
374
If @i{element-type} is the @i{symbol} @b{*},
 
375
@i{arrays} are not excluded on the basis of their @i{element type}.
 
376
Otherwise, only those @i{arrays} are included whose @i{actual array element type}
 
377
 
 
378
is the result of @i{upgrading} @i{element-type};
 
379
see @ref{Array Upgrading}.
 
380
 
 
381
If the @i{dimension-spec} is a @i{rank},
 
382
the set includes only those @i{arrays} having that @i{rank}.
 
383
If the @i{dimension-spec} is a @i{list} of @i{dimensions},
 
384
the set includes only those @i{arrays} having a @i{rank}
 
385
given by the @i{length} of the @i{dimensions},
 
386
and having the indicated @i{dimensions}; 
 
387
in this case, @b{*} matches any value for the corresponding @i{dimension}.
 
388
If the @i{dimension-spec} is the @i{symbol} @b{*},
 
389
the set is not restricted on the basis of @i{rank} or @i{dimension}.
 
390
 
 
391
@subsubheading  See Also::
 
392
 
 
393
@b{*print-array*},
 
394
@ref{aref}
 
395
,
 
396
@ref{make-array}
 
397
,
 
398
@b{vector},
 
399
@ref{Sharpsign A},
 
400
@ref{Printing Other Arrays}
 
401
 
 
402
@subsubheading  Notes::
 
403
 
 
404
Note that the type @t{(array t)}     
 
405
is a proper @i{subtype} of the type @t{(array *)}.
 
406
The reason is that the type @t{(array t)} is the set of @i{arrays} 
 
407
that can
 
408
hold any @i{object} (the @i{elements} are of @i{type} @b{t},  which includes
 
409
all @i{objects}).
 
410
On the other hand, the type @t{(array *)}
 
411
is the set of all @i{arrays} whatsoever, including for example
 
412
@i{arrays} that can hold only @i{characters}. 
 
413
The type @t{(array character)} 
 
414
is not a @i{subtype} of the type @t{(array t)}; 
 
415
the two sets                                              
 
416
are @i{disjoint} because the type @t{(array character)} is not the
 
417
set of all @i{arrays} that can hold 
 
418
@i{characters}, but rather the set of
 
419
@i{arrays} 
 
420
that are specialized to hold precisely @i{characters} and no
 
421
other @i{objects}. 
 
422
 
 
423
@node simple-array, vector (System Class), array, Arrays Dictionary
 
424
@subsection simple-array                                                         [Type]
 
425
 
 
426
@subsubheading  Supertypes:: 
 
427
 
 
428
@b{simple-array},
 
429
@b{array},
 
430
@b{t}
 
431
 
 
432
@subsubheading  Description::
 
433
 
 
434
The @i{type} of an @i{array} that is not displaced 
 
435
to another @i{array}, has no @i{fill pointer}, and is
 
436
not
 
437
@i{expressly adjustable} is a @i{subtype} of @i{type} @b{simple-array}.
 
438
The concept of a @i{simple array}
 
439
exists to allow the implementation to use a specialized representation
 
440
and to allow the user to declare that certain values will always be
 
441
@i{simple arrays}. 
 
442
 
 
443
The @i{types} @b{simple-vector},
 
444
                 @b{simple-string},
 
445
             and @b{simple-bit-vector}
 
446
are @i{disjoint} @i{subtypes} of @i{type} @b{simple-array}, 
 
447
for they respectively mean @t{(simple-array t (*))},
 
448
                           the union of all @t{(simple-array @i{c} (*))} 
 
449
                            for any @i{c} being a @i{subtype} of @i{type} @b{character},
 
450
                        and @t{(simple-array bit (*))}.
 
451
 
 
452
@subsubheading  Compound Type Specifier Kind::
 
453
 
 
454
Specializing.
 
455
 
 
456
@subsubheading  Compound Type Specifier Syntax::
 
457
 
 
458
(@code{simple-array}@{@i{@t{[}@{element-type | @b{*}@} @r{[}dimension-spec@r{]}@t{]}}@})
 
459
 
 
460
@w{@i{dimension-spec} ::=rank | @b{*} | @r{(}@{dimension | @b{*}@}*@r{)}}
 
461
 
 
462
@subsubheading  Compound Type Specifier Arguments::
 
463
 
 
464
@i{dimension}---a @i{valid array dimension}.
 
465
 
 
466
@i{element-type}---a @i{type specifier}.
 
467
 
 
468
@i{rank}---a non-negative @i{fixnum}.
 
469
 
 
470
@subsubheading  Compound Type Specifier Description::
 
471
 
 
472
This @i{compound type specifier} is treated exactly as the corresponding
 
473
@i{compound type specifier} for @i{type} @b{array} would be treated,
 
474
except that the set is further constrained to include only @i{simple arrays}.
 
475
 
 
476
@subsubheading  Notes::
 
477
 
 
478
It is @i{implementation-dependent} 
 
479
whether @i{displaced arrays},
 
480
        @i{vectors} with @i{fill pointers},
 
481
     or arrays that are @i{actually adjustable}
 
482
  are @i{simple arrays}.
 
483
 
 
484
@t{(simple-array *)} refers to all @i{simple arrays} 
 
485
regardless of element type, @t{(simple-array @i{type-specifier})}
 
486
refers only to those @i{simple arrays}
 
487
that can result from giving @i{type-specifier} as the
 
488
@t{:element-type} argument to @b{make-array}.  
 
489
 
 
490
@node vector (System Class), simple-vector, simple-array, Arrays Dictionary
 
491
@subsection vector                                                       [System Class]
 
492
 
 
493
@subsubheading  Class Precedence List::
 
494
@b{vector},
 
495
@b{array},
 
496
@b{sequence},
 
497
@b{t}
 
498
 
 
499
@subsubheading  Description::
 
500
 
 
501
Any one-dimensional @i{array} is a @i{vector}.
 
502
 
 
503
The @i{type} @b{vector} is a @i{subtype} of @i{type} @b{array}; 
 
504
for all @i{types} @t{x}, @t{(vector x)} is the same as @t{(array x (*))}.
 
505
 
 
506
The @i{type} @t{(vector t)}, the @i{type} @b{string}, and the @i{type} @b{bit-vector}
 
507
are @i{disjoint} @i{subtypes} of @i{type} @b{vector}.
 
508
 
 
509
@subsubheading  Compound Type Specifier Kind::
 
510
 
 
511
Specializing.
 
512
 
 
513
@subsubheading  Compound Type Specifier Syntax::
 
514
 
 
515
(@code{vector}@{@i{@t{[}@{element-type | @b{*}@} @r{[}@{size | @b{*}@}@r{]}@t{]}}@})
 
516
 
 
517
@subsubheading  Compound Type Specifier Arguments::
 
518
 
 
519
@i{size}---a non-negative @i{fixnum}.
 
520
 
 
521
@i{element-type}---a @i{type specifier}.
 
522
 
 
523
@subsubheading  Compound Type Specifier Description::
 
524
 
 
525
This denotes the set of specialized @i{vectors}
 
526
whose @i{element type} and @i{dimension} match the specified values.
 
527
Specifically:
 
528
 
 
529
If @i{element-type} is the @i{symbol} @b{*},
 
530
@i{vectors} are not excluded on the basis of their @i{element type}.
 
531
Otherwise, only those @i{vectors} are included whose @i{actual array element type}
 
532
 
 
533
is the result of @i{upgrading} @i{element-type};
 
534
see @ref{Array Upgrading}.
 
535
 
 
536
If a @i{size} is specified,
 
537
the set includes only those @i{vectors} whose only @i{dimension}
 
538
is @i{size}.
 
539
If the @i{symbol} @b{*} is specified instead of a @i{size},
 
540
the set is not restricted on the basis of @i{dimension}.
 
541
 
 
542
@subsubheading  See Also::
 
543
 
 
544
@ref{Required Kinds of Specialized Arrays},
 
545
@ref{Sharpsign Left-Parenthesis},
 
546
@ref{Printing Other Vectors},
 
547
@ref{Sharpsign A}
 
548
 
 
549
@subsubheading  Notes::
 
550
 
 
551
The @i{type} @t{(vector @i{e} @i{s})} 
 
552
is equivalent to the @i{type} @t{(array @i{e} (@i{s}))}.
 
553
 
 
554
The type @t{(vector bit)} has the name @b{bit-vector}.
 
555
 
 
556
The union of all @i{types} @t{(vector C)}, 
 
557
where C is any @i{subtype} of @b{character},
 
558
has the name @b{string}.
 
559
 
 
560
@t{(vector *)} refers to all @i{vectors} 
 
561
regardless of element type, @t{(vector @i{type-specifier})}
 
562
refers only to those @i{vectors} 
 
563
that can result from giving @i{type-specifier} as the
 
564
@t{:element-type} argument to @b{make-array}.  
 
565
 
 
566
@node simple-vector, bit-vector, vector (System Class), Arrays Dictionary
 
567
@subsection simple-vector                                                        [Type]
 
568
 
 
569
@subsubheading  Supertypes::
 
570
 
 
571
@b{simple-vector},
 
572
@b{vector},
 
573
@b{simple-array},
 
574
@b{array},
 
575
@b{sequence},
 
576
@b{t}
 
577
 
 
578
@subsubheading  Description::
 
579
 
 
580
The @i{type} of a @i{vector} that is not displaced to another
 
581
@i{array}, has no @i{fill pointer}, is not 
 
582
@i{expressly adjustable}
 
583
and is able to hold 
 
584
elements of any @i{type} is a @i{subtype} of @i{type} @b{simple-vector}.
 
585
 
 
586
The @i{type} @b{simple-vector} is a @i{subtype} of @i{type} @b{vector},
 
587
and is a @i{subtype} of @i{type} @t{(vector t)}.
 
588
 
 
589
@subsubheading  Compound Type Specifier Kind::
 
590
 
 
591
Specializing.
 
592
 
 
593
@subsubheading  Compound Type Specifier Syntax::
 
594
 
 
595
(@code{simple-vector}@{@i{@t{[}size@t{]}}@})
 
596
 
 
597
@subsubheading  Compound Type Specifier Arguments::
 
598
 
 
599
@i{size}---a non-negative @i{fixnum},
 
600
            or the @i{symbol} @b{*}.
 
601
  The default is the @i{symbol} @b{*}.
 
602
 
 
603
@subsubheading  Compound Type Specifier Description::
 
604
 
 
605
This is the same as @t{(simple-array t (@i{size}))}.
 
606
 
 
607
@node bit-vector, simple-bit-vector, simple-vector, Arrays Dictionary
 
608
@subsection bit-vector                                                   [System Class]
 
609
 
 
610
@subsubheading  Class Precedence List::
 
611
@b{bit-vector},
 
612
@b{vector},
 
613
@b{array},
 
614
@b{sequence},
 
615
@b{t}
 
616
 
 
617
@subsubheading  Description::
 
618
 
 
619
A @i{bit vector} is a @i{vector} the @i{element type} of which is @i{bit}.
 
620
 
 
621
The @i{type} @b{bit-vector} is a @i{subtype} of @i{type} @b{vector}, 
 
622
for @b{bit-vector} means @t{(vector bit)}.
 
623
 
 
624
@subsubheading  Compound Type Specifier Kind::
 
625
 
 
626
Abbreviating.
 
627
 
 
628
@subsubheading  Compound Type Specifier Syntax::
 
629
 
 
630
(@code{bit-vector}@{@i{@t{[}size@t{]}}@})
 
631
 
 
632
@subsubheading  Compound Type Specifier Arguments::
 
633
 
 
634
@i{size}---a non-negative @i{fixnum},
 
635
            or the @i{symbol} @b{*}.
 
636
 
 
637
@subsubheading  Compound Type Specifier Description::
 
638
 
 
639
This denotes the same @i{type} as the @i{type} @t{(array bit (@i{size}))};
 
640
that is, the set of @i{bit vectors} of size @i{size}.
 
641
 
 
642
@subsubheading  See Also::
 
643
 
 
644
@ref{Sharpsign Asterisk},
 
645
@ref{Printing Bit Vectors},
 
646
@ref{Required Kinds of Specialized Arrays}
 
647
 
 
648
@node simple-bit-vector, make-array, bit-vector, Arrays Dictionary
 
649
@subsection simple-bit-vector                                                    [Type]
 
650
 
 
651
@subsubheading  Supertypes:: 
 
652
 
 
653
@b{simple-bit-vector},
 
654
@b{bit-vector},
 
655
@b{vector},
 
656
@b{simple-array},
 
657
@b{array},
 
658
@b{sequence},
 
659
@b{t}
 
660
 
 
661
@subsubheading  Description::
 
662
 
 
663
The @i{type} of a @i{bit vector} that is not displaced
 
664
to another @i{array}, has no @i{fill pointer}, and is 
 
665
not
 
666
@i{expressly adjustable}
 
667
is a
 
668
@i{subtype} of @i{type} @b{simple-bit-vector}.
 
669
 
 
670
@subsubheading  Compound Type Specifier Kind::
 
671
 
 
672
Abbreviating.
 
673
 
 
674
@subsubheading  Compound Type Specifier Syntax::
 
675
 
 
676
(@code{simple-bit-vector}@{@i{@t{[}size@t{]}}@})
 
677
 
 
678
@subsubheading  Compound Type Specifier Arguments::
 
679
 
 
680
@i{size}---a non-negative @i{fixnum},
 
681
            or the @i{symbol} @b{*}.
 
682
  The default is the @i{symbol} @b{*}.
 
683
 
 
684
@subsubheading  Compound Type Specifier Description::
 
685
 
 
686
This denotes the same type as the @i{type}
 
687
@t{(simple-array bit (@i{size}))}; 
 
688
that is, the set of @i{simple bit vectors} of size @i{size}.
 
689
 
 
690
@node make-array, adjust-array, simple-bit-vector, Arrays Dictionary
 
691
@subsection make-array                                                       [Function]
 
692
 
 
693
@code{make-array}  @i{dimensions @r{&key} element-type
 
694
                                                 initial-element
 
695
                                                 initial-contents
 
696
                                                 adjustable
 
697
                                                 fill-pointer
 
698
                                                 displaced-to
 
699
                                                 displaced-index-offset}@*
 
700
   @result{}  @i{new-array}
 
701
 
 
702
@subsubheading  Arguments and Values::
 
703
 
 
704
@i{dimensions}---a @i{designator} for a @i{list} of @i{valid array dimensions}.
 
705
 
 
706
@i{element-type}---a @i{type specifier}. 
 
707
 The default is @b{t}.
 
708
 
 
709
@i{initial-element}---an @i{object}.
 
710
 
 
711
@i{initial-contents}---an @i{object}.
 
712
 
 
713
@i{adjustable}---a @i{generalized boolean}.
 
714
 The default is @b{nil}.
 
715
 
 
716
@i{fill-pointer}---a @i{valid fill pointer} for the @i{array} to be created,
 
717
                       or @b{t} or @b{nil}.
 
718
 The default is @b{nil}.
 
719
 
 
720
@i{displaced-to}---an @i{array} or @b{nil}.
 
721
 The default is @b{nil}.
 
722
 This option must not be supplied if either @i{initial-element}
 
723
 or @i{initial-contents} is supplied.
 
724
 
 
725
@i{displaced-index-offset}---a @i{valid array row-major index} 
 
726
 for @i{displaced-to}. The default is @t{0}.
 
727
 This option must not be supplied unless a @i{non-nil} @i{displaced-to} is supplied.
 
728
 
 
729
@i{new-array}---an @i{array}.
 
730
 
 
731
@subsubheading  Description::
 
732
 
 
733
Creates and returns an @i{array} constructed of the most @i{specialized}
 
734
@i{type} that can accommodate elements of @i{type} given by @i{element-type}.
 
735
If @i{dimensions} is @b{nil} then a zero-dimensional @i{array} is created.
 
736
 
 
737
@i{Dimensions} represents the dimensionality of the new @i{array}.
 
738
 
 
739
@i{element-type} indicates the @i{type} of the elements intended to be stored
 
740
in the @i{new-array}.  The @i{new-array} can actually store any @i{objects}
 
741
of the @i{type} which results from @i{upgrading} @i{element-type};
 
742
see @ref{Array Upgrading}.
 
743
 
 
744
If @i{initial-element} is supplied, 
 
745
it is used to initialize each @i{element} of @i{new-array}. 
 
746
If @i{initial-element} is supplied,
 
747
it must be of the @i{type} given by @i{element-type}.
 
748
@i{initial-element} cannot be supplied if either the @t{:initial-contents} option
 
749
is supplied or @i{displaced-to} is @i{non-nil}.
 
750
If @i{initial-element} is not supplied,
 
751
 
 
752
the consequences of later reading an uninitialized @i{element} of @i{new-array}
 
753
are undefined
 
754
 
 
755
unless either @i{initial-contents} is supplied 
 
756
or @i{displaced-to} is @i{non-nil}.
 
757
 
 
758
@i{initial-contents} is used to initialize the contents of @i{array}.
 
759
For example:
 
760
 
 
761
@example
 
762
 (make-array '(4 2 3) :initial-contents
 
763
             '(((a b c) (1 2 3))
 
764
              ((d e f) (3 1 2))
 
765
              ((g h i) (2 3 1))
 
766
              ((j k l) (0 0 0))))
 
767
@end example
 
768
 
 
769
@i{initial-contents} is composed of a nested structure of @i{sequences}. 
 
770
The numbers of levels in the structure must equal the rank of @i{array}.
 
771
Each leaf of the nested structure must be of the @i{type} given by @i{element-type}. 
 
772
If @i{array} is zero-dimensional, then @i{initial-contents} specifies the single
 
773
@i{element}.  Otherwise, @i{initial-contents} must be a @i{sequence}
 
774
whose length is equal to the first dimension; each element must be a nested 
 
775
structure for an @i{array} whose dimensions are the remaining dimensions, 
 
776
and so on.
 
777
@i{Initial-contents} cannot be supplied if either 
 
778
@i{initial-element} is supplied
 
779
or @i{displaced-to} is @i{non-nil}.
 
780
If @i{initial-contents} is not supplied,
 
781
 
 
782
the consequences of later reading an uninitialized @i{element} of @i{new-array}
 
783
are undefined
 
784
 
 
785
unless either @i{initial-element} is supplied
 
786
or @i{displaced-to} is @i{non-nil}.
 
787
 
 
788
If @i{adjustable} is @i{non-nil},
 
789
the array is @i{expressly adjustable} 
 
790
              (and so @i{actually adjustable});
 
791
otherwise, the array is not @i{expressly adjustable} 
 
792
       (and it is @i{implementation-dependent} whether 
 
793
            the array is @i{actually adjustable}).
 
794
 
 
795
If @i{fill-pointer} is @i{non-nil},
 
796
the @i{array} must be one-dimensional;
 
797
that is, the @i{array} must be a @i{vector}.
 
798
If @i{fill-pointer} is @b{t},
 
799
the length of the @i{vector} is used to initialize the @i{fill pointer}.
 
800
If @i{fill-pointer} is an @i{integer},
 
801
it becomes the initial @i{fill pointer} for the @i{vector}.
 
802
 
 
803
If @i{displaced-to} is @i{non-nil},
 
804
@b{make-array} will create a @i{displaced array} 
 
805
and @i{displaced-to} is the @i{target} of that @i{displaced array}. 
 
806
In that case, the consequences are undefined if the @i{actual array element type} of 
 
807
@i{displaced-to} is not @i{type equivalent} to the @i{actual array element type}
 
808
of the @i{array} being created.
 
809
If @i{displaced-to} is @b{nil}, the @i{array} is not a @i{displaced array}.
 
810
 
 
811
The @i{displaced-index-offset} is made to be the index offset of the @i{array}.
 
812
When an array A is given as
 
813
the @t{:displaced-to} @i{argument} to @b{make-array} 
 
814
when creating array B,
 
815
then array B is said to be displaced to array A.  The
 
816
total number of elements in an @i{array}, 
 
817
called the total size of the @i{array},
 
818
is calculated as the product of all the dimensions.
 
819
It is required that the total size of A be no smaller than the sum
 
820
of the total size of B plus the offset @t{n} supplied by
 
821
the @i{displaced-index-offset}.
 
822
The effect of displacing is that array B does not have any
 
823
elements of its own, but instead maps @i{accesses} to itself into
 
824
@i{accesses} to array A.  The mapping treats both @i{arrays} as if they
 
825
were one-dimensional by taking the elements in row-major order,
 
826
and then maps an @i{access} to element @t{k} of array B to an @i{access} to element
 
827
@t{k}+@t{n} of array A.
 
828
 
 
829
If @b{make-array} is called with @i{adjustable}, @i{fill-pointer},
 
830
and @i{displaced-to} each @b{nil}, 
 
831
then the result is a @i{simple array}.
 
832
 
 
833
If @b{make-array} is called with one or more of @i{adjustable},
 
834
@i{fill-pointer}, or @i{displaced-to} being @i{true}, whether the
 
835
resulting @i{array} is a @i{simple array} is @i{implementation-dependent}.
 
836
 
 
837
  When an array A is given as the @t{:displaced-to} @i{argument} to
 
838
  @b{make-array} when creating array B, then array B is said to
 
839
  be displaced to array A.  The total number of elements in an @i{array}, 
 
840
  called the total size of the @i{array}, is calculated as the product
 
841
  of all the dimensions.
 
842
The consequences are unspecified if
 
843
the total size of A is smaller than the sum
 
844
of the total size of B plus the offset @t{n} supplied by
 
845
the @i{displaced-index-offset}.
 
846
The effect of displacing is that array B does not have any
 
847
elements of its own, but instead maps @i{accesses} to itself into
 
848
@i{accesses} to array A.  The mapping treats both @i{arrays} as if they
 
849
were one-dimensional by taking the elements in row-major order,
 
850
and then maps an @i{access} to element @t{k} of array B to an @i{access} 
 
851
to @i{element} @t{k}+@t{n} of array A.
 
852
 
 
853
@subsubheading  Examples::
 
854
@example
 
855
 
 
856
 (make-array 5) ;; Creates a one-dimensional array of five elements.
 
857
 (make-array '(3 4) :element-type '(mod 16)) ;; Creates a 
 
858
                ;;two-dimensional array, 3 by 4, with four-bit elements.
 
859
 (make-array 5 :element-type 'single-float) ;; Creates an array of single-floats.
 
860
@end example
 
861
 
 
862
@example
 
863
 (make-array nil :initial-element nil) @result{}  #0ANIL
 
864
 (make-array 4 :initial-element nil) @result{}  #(NIL NIL NIL NIL)
 
865
 (make-array '(2 4) 
 
866
              :element-type '(unsigned-byte 2) 
 
867
              :initial-contents '((0 1 2 3) (3 2 1 0)))
 
868
@result{}  #2A((0 1 2 3) (3 2 1 0))
 
869
 (make-array 6
 
870
              :element-type 'character 
 
871
              :initial-element #\a 
 
872
              :fill-pointer 3) @result{}  "aaa"
 
873
@end example
 
874
 
 
875
The following is an example of making a @i{displaced array}.
 
876
 
 
877
@example
 
878
 (setq a (make-array '(4 3))) 
 
879
@result{}  #<ARRAY 4x3 simple 32546632>
 
880
 (dotimes (i 4)
 
881
   (dotimes (j 3)
 
882
     (setf (aref a i j) (list i 'x j '= (* i j)))))
 
883
@result{}  NIL
 
884
 (setq b (make-array 8 :displaced-to a
 
885
                       :displaced-index-offset 2))
 
886
@result{}  #<ARRAY 8 indirect 32550757>
 
887
 (dotimes (i 8)
 
888
   (print (list i (aref b i))))
 
889
@t{ |> } (0 (0 X 2 = 0)) 
 
890
@t{ |> } (1 (1 X 0 = 0)) 
 
891
@t{ |> } (2 (1 X 1 = 1)) 
 
892
@t{ |> } (3 (1 X 2 = 2)) 
 
893
@t{ |> } (4 (2 X 0 = 0)) 
 
894
@t{ |> } (5 (2 X 1 = 2)) 
 
895
@t{ |> } (6 (2 X 2 = 4)) 
 
896
@t{ |> } (7 (3 X 0 = 0)) 
 
897
@result{}  NIL
 
898
@end example
 
899
 
 
900
The last example depends on the fact that @i{arrays} are, in effect,
 
901
stored in row-major order. 
 
902
 
 
903
@example
 
904
 (setq a1 (make-array 50))
 
905
@result{}  #<ARRAY 50 simple 32562043>
 
906
 (setq b1 (make-array 20 :displaced-to a1 :displaced-index-offset 10))
 
907
@result{}  #<ARRAY 20 indirect 32563346>
 
908
 (length b1) @result{}  20
 
909
 
 
910
 (setq a2 (make-array 50 :fill-pointer 10))
 
911
@result{}  #<ARRAY 50 fill-pointer 10 46100216>
 
912
 (setq b2 (make-array 20 :displaced-to a2 :displaced-index-offset 10))
 
913
@result{}  #<ARRAY 20 indirect 46104010>
 
914
 (length a2) @result{}  10
 
915
 (length b2) @result{}  20
 
916
 
 
917
 (setq a3 (make-array 50 :fill-pointer 10))
 
918
@result{}  #<ARRAY 50 fill-pointer 10 46105663>
 
919
 (setq b3 (make-array 20 :displaced-to a3 :displaced-index-offset 10
 
920
                         :fill-pointer 5))
 
921
@result{}  #<ARRAY 20 indirect, fill-pointer 5 46107432>
 
922
 (length a3) @result{}  10
 
923
 (length b3) @result{}  5
 
924
@end example
 
925
 
 
926
@subsubheading  See Also::
 
927
 
 
928
@ref{adjustable-array-p}
 
929
,
 
930
@ref{aref}
 
931
,
 
932
@ref{arrayp}
 
933
,
 
934
@ref{array-element-type}
 
935
,
 
936
@ref{array-rank-limit}
 
937
,
 
938
@ref{array-dimension-limit}
 
939
,
 
940
@ref{fill-pointer}
 
941
,
 
942
@ref{upgraded-array-element-type}
 
943
 
 
944
@subsubheading  Notes::
 
945
 
 
946
There is no specified way to create an @i{array} 
 
947
for which @b{adjustable-array-p} definitely
 
948
returns @i{false}.
 
949
There is no specified way to create an @i{array} 
 
950
that is not a @i{simple array}.
 
951
 
 
952
@node adjust-array, adjustable-array-p, make-array, Arrays Dictionary
 
953
@subsection adjust-array                                                     [Function]
 
954
 
 
955
@code{adjust-array}  @i{array new-dimensions @r{&key} element-type
 
956
                                                           initial-element
 
957
                                                           initial-contents
 
958
                                                           fill-pointer
 
959
                                                           displaced-to
 
960
                                                           displaced-index-offset}@*
 
961
   @result{}  @i{adjusted-array}
 
962
 
 
963
@subsubheading  Arguments and Values:: 
 
964
 
 
965
@i{array}---an @i{array}.
 
966
 
 
967
@i{new-dimensions}---a @i{valid array dimension} 
 
968
                      or a @i{list} of @i{valid array dimensions}.
 
969
 
 
970
@i{element-type}---a @i{type specifier}.
 
971
 
 
972
@i{initial-element}---an @i{object}.
 
973
  @i{Initial-element} must not be supplied if either 
 
974
  @i{initial-contents} or @i{displaced-to} is supplied.
 
975
 
 
976
@i{initial-contents}---an @i{object}.
 
977
 If @i{array} has rank greater than zero, then @i{initial-contents}
 
978
 is composed of nested @i{sequences}, the depth of which must equal
 
979
 the rank of @i{array}.  Otherwise, @i{array} is zero-dimensional and
 
980
 @i{initial-contents} supplies the single element.
 
981
 @i{initial-contents} must not be supplied if either 
 
982
 @i{initial-element} or @i{displaced-to} is given.
 
983
 
 
984
@i{fill-pointer}---a @i{valid fill pointer} for the
 
985
 @i{array} to be created, or @b{t}, or @b{nil}.
 
986
 The default is @b{nil}.
 
987
 
 
988
@i{displaced-to}---an @i{array} or @b{nil}.
 
989
 @i{initial-elements} and @i{initial-contents} must not be supplied
 
990
 if @i{displaced-to} is supplied.
 
991
 
 
992
@i{displaced-index-offset}---an @i{object} of @i{type} @t{(fixnum 0 @i{n})} 
 
993
 where @i{n} is @t{(array-total-size @i{displaced-to})}.
 
994
 @i{displaced-index-offset} may be supplied only if @i{displaced-to} is supplied.
 
995
 
 
996
@i{adjusted-array}---an @i{array}.
 
997
 
 
998
@subsubheading  Description::
 
999
 
 
1000
@b{adjust-array} changes the dimensions or elements of @i{array}.
 
1001
The result is an @i{array} of the same @i{type} and rank as @i{array},
 
1002
that is either the modified @i{array},
 
1003
or a newly created @i{array} to which
 
1004
@i{array} can be displaced, and that has 
 
1005
the given @i{new-dimensions}.
 
1006
 
 
1007
@i{New-dimensions} specify the size of each @i{dimension} of @i{array}. 
 
1008
 
 
1009
@i{Element-type} specifies the @i{type} of the @i{elements}
 
1010
of the resulting @i{array}.  If @i{element-type} is supplied,
 
1011
the consequences are unspecified if
 
1012
the @i{upgraded array element type} of @i{element-type}
 
1013
is not the same as the @i{actual array element type} of @i{array}.
 
1014
 
 
1015
If @i{initial-contents} is supplied, it is treated as for
 
1016
@b{make-array}.  In this case none of the original contents of
 
1017
@i{array} appears in the resulting @i{array}.
 
1018
 
 
1019
If @i{fill-pointer} is an @i{integer},
 
1020
it becomes the @i{fill pointer} for the resulting @i{array}.
 
1021
If @i{fill-pointer} is the symbol @b{t},
 
1022
it indicates that the size of the resulting @i{array} 
 
1023
should be used as the @i{fill pointer}.
 
1024
If @i{fill-pointer} is @b{nil},
 
1025
it indicates that the @i{fill pointer} should be left as it is.
 
1026
 
 
1027
If @i{displaced-to}
 
1028
@i{non-nil}, a @i{displaced array}
 
1029
is created. The resulting @i{array} shares its contents with the @i{array} given by
 
1030
@i{displaced-to}.
 
1031
The resulting @i{array} cannot contain more elements than the @i{array}
 
1032
it is displaced to.  
 
1033
If @i{displaced-to} is not supplied or @b{nil},
 
1034
the resulting @i{array} is not a @i{displaced array}.
 
1035
If array A is created displaced to array B and subsequently
 
1036
array B is given to @b{adjust-array}, array A will still be
 
1037
displaced to array B.
 
1038
Although @i{array} might be a @i{displaced array}, 
 
1039
the resulting @i{array} is not a @i{displaced array} unless
 
1040
@i{displaced-to} is supplied and not @b{nil}.
 
1041
 
 
1042
The interaction between @b{adjust-array} and 
 
1043
displaced @i{arrays} 
 
1044
is as follows given three @i{arrays}, @t{A}, @t{B}, and~@t{C}:
 
1045
 
 
1046
@table @asis
 
1047
 
 
1048
@item @t{A} is not displaced before or after the call  
 
1049
@example
 
1050
 (adjust-array A ...)
 
1051
@end example
 
1052
 
 
1053
The dimensions of @t{A} are altered, and the
 
1054
contents rearranged as appropriate.  
 
1055
Additional elements of @t{A} are taken from
 
1056
@i{initial-element}.  
 
1057
The use of @i{initial-contents} causes all old contents to be
 
1058
discarded.
 
1059
 
 
1060
@item @t{A} is not displaced before, but is displaced to 
 
1061
@t{C} after the call  
 
1062
@example
 
1063
 (adjust-array A ... :displaced-to C)
 
1064
@end example
 
1065
 
 
1066
None of the original contents of @t{A} appears in 
 
1067
@t{A} afterwards; @t{A} now contains
 
1068
the contents of @t{C}, without any rearrangement of @t{C}.
 
1069
 
 
1070
@item @t{A} is displaced to @t{B} 
 
1071
before the call, and is displaced to @t{C} after 
 
1072
the call  
 
1073
@example
 
1074
 (adjust-array A ... :displaced-to B)
 
1075
 (adjust-array A ... :displaced-to C)
 
1076
@end example
 
1077
 
 
1078
@t{B} and @t{C} might be the same. The contents of @t{B} do not appear in 
 
1079
@t{A} afterward unless such contents also happen to be in @t{C}  If
 
1080
@i{displaced-index-offset} 
 
1081
is not supplied in the @b{adjust-array} call, it defaults
 
1082
to zero; the old offset into @t{B} is not retained.
 
1083
 
 
1084
@item @t{A} is displaced to @t{B} before the call, but not displaced
 
1085
afterward.  
 
1086
@example
 
1087
 (adjust-array A ... :displaced-to B)
 
1088
 (adjust-array A ... :displaced-to nil)
 
1089
@end example
 
1090
 
 
1091
@t{A} gets a
 
1092
new ``data region,'' and contents of @t{B} are copied into it as appropriate to
 
1093
maintain the existing old contents; additional elements of @t{A} 
 
1094
are taken from
 
1095
@i{initial-element} if supplied.  However, 
 
1096
the use of @i{initial-contents} causes all old contents
 
1097
to be discarded.
 
1098
@end table
 
1099
 
 
1100
If @i{displaced-index-offset} is supplied,
 
1101
it specifies the offset
 
1102
of the resulting @i{array} from the beginning of 
 
1103
the @i{array} that it is displaced to.           
 
1104
If @i{displaced-index-offset} is not supplied, the offset is~0.  
 
1105
The size of the resulting @i{array} plus the 
 
1106
offset value cannot exceed the size of
 
1107
the @i{array} that it is displaced to.
 
1108
 
 
1109
If only @i{new-dimensions}
 
1110
and an @i{initial-element} argument are supplied,
 
1111
those elements of @i{array} that
 
1112
are still in bounds appear in the resulting @i{array}. The elements of
 
1113
the resulting @i{array} that are not in the bounds of 
 
1114
@i{array} are initialized
 
1115
to @i{initial-element}; if @i{initial-element} is not provided,
 
1116
 
 
1117
the consequences of later reading any such new @i{element} of @i{new-array}
 
1118
before it has been initialized
 
1119
are undefined.
 
1120
 
 
1121
If @i{initial-contents} or @i{displaced-to} is supplied,
 
1122
then none of the original contents of @i{array} appears in the new @i{array}.
 
1123
 
 
1124
The consequences are unspecified if @i{array} is adjusted 
 
1125
to a size smaller than its @i{fill pointer} without supplying
 
1126
the @i{fill-pointer} argument so that its @i{fill-pointer}
 
1127
is properly adjusted in the process.
 
1128
 
 
1129
If @t{A} is displaced to @t{B}, the consequences are unspecified 
 
1130
if @t{B} is adjusted in such a way that it no longer has enough elements
 
1131
to satisfy @t{A}.  
 
1132
 
 
1133
If @b{adjust-array} is applied to an @i{array} that is @i{actually adjustable},
 
1134
the @i{array} returned is @i{identical} to @i{array}.
 
1135
If the @i{array} returned by @b{adjust-array} 
 
1136
is @i{distinct} from @i{array}, then the argument @i{array} is unchanged.
 
1137
 
 
1138
Note that if an @i{array} A is displaced to another @i{array} B,
 
1139
and B is displaced to another @i{array} C, and B is altered by
 
1140
@b{adjust-array}, A must now refer to the adjust contents of B.
 
1141
This means that an implementation cannot collapse the chain to make A
 
1142
refer to C directly and forget that the chain of reference passes through
 
1143
B.  However, caching techniques are permitted as long as they preserve the 
 
1144
semantics specified here.
 
1145
 
 
1146
@subsubheading  Examples::
 
1147
 
 
1148
@example
 
1149
 (adjustable-array-p
 
1150
  (setq ada (adjust-array
 
1151
              (make-array '(2 3)
 
1152
                          :adjustable t
 
1153
                          :initial-contents '((a b c) (1 2 3)))
 
1154
              '(4 6)))) @result{}  T 
 
1155
 (array-dimensions ada) @result{}  (4 6) 
 
1156
 (aref ada 1 1) @result{}  2 
 
1157
 (setq beta (make-array '(2 3) :adjustable t))
 
1158
@result{}  #2A((NIL NIL NIL) (NIL NIL NIL)) 
 
1159
 (adjust-array beta '(4 6) :displaced-to ada)
 
1160
@result{}  #2A((A B C NIL NIL NIL)
 
1161
       (1 2 3 NIL NIL NIL)
 
1162
       (NIL NIL NIL NIL NIL NIL) 
 
1163
       (NIL NIL NIL NIL NIL NIL))
 
1164
 (array-dimensions beta) @result{}  (4 6)
 
1165
 (aref beta 1 1) @result{}  2 
 
1166
@end example
 
1167
 
 
1168
Suppose that the 4-by-4 array in @t{m} looks like this:
 
1169
 
 
1170
@example
 
1171
#2A(( alpha     beta      gamma     delta )
 
1172
    ( epsilon   zeta      eta       theta )
 
1173
    ( iota      kappa     lambda    mu    )
 
1174
    ( nu        xi        omicron   pi    ))
 
1175
@end example
 
1176
 
 
1177
Then the result of
 
1178
 
 
1179
@example
 
1180
 (adjust-array m '(3 5) :initial-element 'baz)
 
1181
@end example
 
1182
 
 
1183
is a 3-by-5 array with contents       
 
1184
 
 
1185
@example
 
1186
#2A(( alpha     beta      gamma     delta     baz )
 
1187
    ( epsilon   zeta      eta       theta     baz )
 
1188
    ( iota      kappa     lambda    mu        baz ))
 
1189
@end example
 
1190
 
 
1191
@subsubheading  Exceptional Situations::
 
1192
 
 
1193
An error of @i{type} @b{error} is signaled if @i{fill-pointer} is supplied
 
1194
and @i{non-nil} but @i{array} has no @i{fill pointer}.
 
1195
 
 
1196
@subsubheading  See Also::
 
1197
 
 
1198
@ref{adjustable-array-p}
 
1199
,    
 
1200
@ref{make-array}
 
1201
,
 
1202
@ref{array-dimension-limit}
 
1203
 
1204
@ref{array-total-size-limit}
 
1205
,
 
1206
@b{array}
 
1207
 
 
1208
@node adjustable-array-p, aref, adjust-array, Arrays Dictionary
 
1209
@subsection adjustable-array-p                                               [Function]
 
1210
 
 
1211
@code{adjustable-array-p}  @i{array} @result{}  @i{generalized-boolean}
 
1212
 
 
1213
@subsubheading  Arguments and Values::
 
1214
 
 
1215
@i{array}---an @i{array}.
 
1216
 
 
1217
@i{generalized-boolean}---a @i{generalized boolean}.
 
1218
 
 
1219
@subsubheading  Description::
 
1220
 
 
1221
Returns true if and only if @b{adjust-array} could return a @i{value}
 
1222
which is @i{identical} to @i{array} when given that @i{array} as its
 
1223
first @i{argument}.
 
1224
 
 
1225
@subsubheading  Examples::
 
1226
 
 
1227
@example
 
1228
 (adjustable-array-p 
 
1229
   (make-array 5
 
1230
               :element-type 'character 
 
1231
               :adjustable t 
 
1232
               :fill-pointer 3)) @result{}  @i{true}
 
1233
 (adjustable-array-p (make-array 4)) @result{}  @i{implementation-dependent}
 
1234
@end example
 
1235
 
 
1236
@subsubheading  Exceptional Situations::
 
1237
 
 
1238
Should signal an error of @i{type} @b{type-error} if its argument is not an @i{array}.
 
1239
 
 
1240
@subsubheading  See Also::
 
1241
 
 
1242
@ref{adjust-array}
 
1243
 
1244
@ref{make-array}
 
1245
 
 
1246
@node aref, array-dimension, adjustable-array-p, Arrays Dictionary
 
1247
@subsection aref                                                             [Accessor]
 
1248
 
 
1249
@code{aref}  @i{array @r{&rest} subscripts} @result{}  @i{element}
 
1250
 
 
1251
(setf (@code{         aref} @i{array @r{&rest} subscripts}) new-element)@*
 
1252
 
 
1253
@subsubheading  Arguments and Values::
 
1254
 
 
1255
@i{array}---an @i{array}.
 
1256
 
 
1257
@i{subscripts}---a @i{list} of @i{valid array indices} for the @i{array}.
 
1258
 
 
1259
@i{element}, @i{new-element}---an @i{object}.
 
1260
 
 
1261
@subsubheading  Description::
 
1262
 
 
1263
@i{Accesses} the @i{array} @i{element} specified by the @i{subscripts}.
 
1264
If no @i{subscripts} are supplied and @i{array} is zero rank,
 
1265
@b{aref} @i{accesses} the sole element of @i{array}.
 
1266
 
 
1267
@b{aref} ignores @i{fill pointers}.
 
1268
It is permissible to use @b{aref} 
 
1269
to @i{access} any @i{array} @i{element},
 
1270
whether @i{active} or not.
 
1271
 
 
1272
@subsubheading  Examples::
 
1273
 
 
1274
If the variable @t{foo} names a 3-by-5 array,
 
1275
then the first index could be 0, 1, or 2, and then second index
 
1276
could be 0, 1, 2, 3, or 4.  The array elements can be referred to by using
 
1277
the @i{function} @b{aref}; for example, @t{(aref foo 2 1)}
 
1278
refers to element (2, 1) of the array.  
 
1279
 
 
1280
@example
 
1281
 (aref (setq alpha (make-array 4)) 3) @result{}  @i{implementation-dependent}
 
1282
 (setf (aref alpha 3) 'sirens) @result{}  SIRENS
 
1283
 (aref alpha 3) @result{}  SIRENS
 
1284
 (aref (setq beta (make-array '(2 4) 
 
1285
                    :element-type '(unsigned-byte 2)
 
1286
                    :initial-contents '((0 1 2 3) (3 2 1 0))))
 
1287
        1 2) @result{}  1
 
1288
 (setq gamma '(0 2))
 
1289
 (apply #'aref beta gamma) @result{}  2
 
1290
 (setf (apply #'aref beta gamma) 3) @result{}  3
 
1291
 (apply #'aref beta gamma) @result{}  3
 
1292
 (aref beta 0 2) @result{}  3
 
1293
@end example
 
1294
 
 
1295
@subsubheading  See Also::
 
1296
 
 
1297
@ref{bit (Array)}
 
1298
,
 
1299
@ref{char}
 
1300
,
 
1301
@ref{elt}
 
1302
,
 
1303
@ref{row-major-aref}
 
1304
,
 
1305
@ref{svref}
 
1306
,
 
1307
 
 
1308
@ref{Compiler Terminology}
 
1309
 
 
1310
@node array-dimension, array-dimensions, aref, Arrays Dictionary
 
1311
@subsection array-dimension                                                  [Function]
 
1312
 
 
1313
@code{array-dimension}  @i{array axis-number} @result{}  @i{dimension}
 
1314
 
 
1315
@subsubheading  Arguments and Values::
 
1316
 
 
1317
@i{array}---an @i{array}.
 
1318
 
 
1319
@i{axis-number}---an @i{integer} greater than or equal to zero
 
1320
                      and less than the @i{rank} of the @i{array}.
 
1321
 
 
1322
@i{dimension}---a non-negative @i{integer}.
 
1323
 
 
1324
@subsubheading  Description::
 
1325
 
 
1326
@b{array-dimension} returns the @i{axis-number} 
 
1327
@i{dimension}_1 of @i{array}.
 
1328
(Any @i{fill pointer} is ignored.)
 
1329
 
 
1330
@subsubheading  Examples::
 
1331
 
 
1332
@example
 
1333
 (array-dimension (make-array 4) 0) @result{}  4
 
1334
 (array-dimension (make-array '(2 3)) 1) @result{}  3
 
1335
@end example
 
1336
 
 
1337
@subsubheading  Affected By::    
 
1338
None.
 
1339
 
 
1340
@subsubheading  See Also::
 
1341
 
 
1342
@ref{array-dimensions}
 
1343
 
1344
@ref{length}
 
1345
 
 
1346
@subsubheading  Notes::
 
1347
@example
 
1348
 (array-dimension array n) @equiv{} (nth n (array-dimensions array))
 
1349
@end example
 
1350
 
 
1351
@node array-dimensions, array-element-type, array-dimension, Arrays Dictionary
 
1352
@subsection array-dimensions                                                 [Function]
 
1353
 
 
1354
@code{array-dimensions}  @i{array} @result{}  @i{dimensions}
 
1355
 
 
1356
@subsubheading  Arguments and Values::
 
1357
 
 
1358
@i{array}---an @i{array}.
 
1359
 
 
1360
@i{dimensions}---a @i{list} of @i{integers}.
 
1361
 
 
1362
@subsubheading  Description::                    
 
1363
 
 
1364
Returns a @i{list} of the @i{dimensions} of @i{array}.
 
1365
(If @i{array} is a @i{vector} with a @i{fill pointer}, 
 
1366
 that @i{fill pointer} is ignored.)
 
1367
 
 
1368
@subsubheading  Examples::
 
1369
 
 
1370
@example
 
1371
 (array-dimensions (make-array 4)) @result{}  (4)
 
1372
 (array-dimensions (make-array '(2 3))) @result{}  (2 3)
 
1373
 (array-dimensions (make-array 4 :fill-pointer 2)) @result{}  (4)
 
1374
@end example
 
1375
 
 
1376
@subsubheading  Exceptional Situations::
 
1377
 
 
1378
Should signal an error of @i{type} @b{type-error} if its argument is not an @i{array}.
 
1379
 
 
1380
@subsubheading  See Also::
 
1381
 
 
1382
@ref{array-dimension}
 
1383
 
 
1384
@node array-element-type, array-has-fill-pointer-p, array-dimensions, Arrays Dictionary
 
1385
@subsection array-element-type                                               [Function]
 
1386
 
 
1387
@code{array-element-type}  @i{array} @result{}  @i{typespec}
 
1388
 
 
1389
@subsubheading  Arguments and Values::
 
1390
 
 
1391
@i{array}---an @i{array}.
 
1392
 
 
1393
@i{typespec}---a @i{type specifier}.
 
1394
 
 
1395
@subsubheading  Description::
 
1396
 
 
1397
Returns a @i{type specifier} which represents the @i{actual array element type}
 
1398
of the array, which is the set of @i{objects} that such an @i{array} can hold.
 
1399
(Because of @i{array} @i{upgrading}, this @i{type specifier} can in
 
1400
some cases denote a @i{supertype} of the @i{expressed array element type}
 
1401
of the @i{array}.)
 
1402
 
 
1403
@subsubheading  Examples::
 
1404
 
 
1405
@example
 
1406
 (array-element-type (make-array 4)) @result{}  T
 
1407
 (array-element-type (make-array 12 :element-type '(unsigned-byte 8))) 
 
1408
@result{}  @i{implementation-dependent}
 
1409
 (array-element-type (make-array 12 :element-type '(unsigned-byte 5)))
 
1410
@result{}  @i{implementation-dependent}
 
1411
@end example
 
1412
 
 
1413
@example
 
1414
 (array-element-type (make-array 5 :element-type '(mod 5)))
 
1415
@end example
 
1416
 
 
1417
could be @t{(mod 5)}, @t{(mod 8)}, @t{fixnum}, @t{t}, or any other
 
1418
type of which @t{(mod 5)} is a @i{subtype}.
 
1419
 
 
1420
@subsubheading  Affected By::
 
1421
 
 
1422
The @i{implementation}.
 
1423
 
 
1424
@subsubheading  Exceptional Situations::
 
1425
 
 
1426
Should signal an error of @i{type} @b{type-error} if its argument is not an @i{array}.
 
1427
 
 
1428
@subsubheading  See Also::
 
1429
 
 
1430
@b{array},
 
1431
@ref{make-array}
 
1432
,
 
1433
@ref{subtypep}
 
1434
,
 
1435
@ref{upgraded-array-element-type}
 
1436
 
 
1437
@node array-has-fill-pointer-p, array-displacement, array-element-type, Arrays Dictionary
 
1438
@subsection array-has-fill-pointer-p                                         [Function]
 
1439
 
 
1440
@code{array-has-fill-pointer-p}  @i{array} @result{}  @i{generalized-boolean}
 
1441
 
 
1442
@subsubheading  Arguments and Values::
 
1443
 
 
1444
@i{array}---an @i{array}.
 
1445
 
 
1446
@i{generalized-boolean}---a @i{generalized boolean}.
 
1447
 
 
1448
@subsubheading  Description::
 
1449
 
 
1450
Returns @i{true} if @i{array} has a @i{fill pointer};
 
1451
otherwise returns @i{false}.
 
1452
 
 
1453
@subsubheading  Examples::
 
1454
 
 
1455
@example
 
1456
 (array-has-fill-pointer-p (make-array 4)) @result{}  @i{implementation-dependent}
 
1457
 (array-has-fill-pointer-p (make-array '(2 3))) @result{}  @i{false}
 
1458
 (array-has-fill-pointer-p
 
1459
   (make-array 8 
 
1460
               :fill-pointer 2 
 
1461
               :initial-element 'filler)) @result{}  @i{true}
 
1462
@end example
 
1463
 
 
1464
@subsubheading  Exceptional Situations::
 
1465
 
 
1466
Should signal an error of @i{type} @b{type-error} if its argument is not an @i{array}.
 
1467
 
 
1468
@subsubheading  See Also::
 
1469
 
 
1470
@ref{make-array}
 
1471
 
1472
@ref{fill-pointer}
 
1473
 
 
1474
@subsubheading  Notes::
 
1475
 
 
1476
Since @i{arrays} of @i{rank} other than one cannot have a @i{fill pointer},
 
1477
@b{array-has-fill-pointer-p} always returns @b{nil} when its argument
 
1478
is such an array.
 
1479
 
 
1480
@node array-displacement, array-in-bounds-p, array-has-fill-pointer-p, Arrays Dictionary
 
1481
@subsection array-displacement                                               [Function]
 
1482
 
 
1483
@code{array-displacement}  @i{array} @result{}  @i{displaced-to, displaced-index-offset}
 
1484
 
 
1485
@subsubheading  Arguments and Values::
 
1486
 
 
1487
@i{array}---an @i{array}.
 
1488
 
 
1489
@i{displaced-to}---an @i{array} or @b{nil}.
 
1490
 
 
1491
@i{displaced-index-offset}---a non-negative @i{fixnum}.
 
1492
 
 
1493
@subsubheading  Description::
 
1494
 
 
1495
If the @i{array} is a @i{displaced array},
 
1496
returns the @i{values} of the @t{:displaced-to} and @t{:displaced-index-offset}
 
1497
options
 
1498
for the @i{array} (see the @i{functions} @b{make-array} and @b{adjust-array}).
 
1499
If the @i{array} is not a @i{displaced array},
 
1500
@b{nil} and @t{0} are returned.
 
1501
 
 
1502
If @b{array-displacement} is called on an @i{array}
 
1503
for which a @i{non-nil} @i{object} was provided as the
 
1504
@t{:displaced-to} @i{argument} to @b{make-array} 
 
1505
or @b{adjust-array}, it must return that @i{object}
 
1506
as its first value. It is @i{implementation-dependent}
 
1507
whether @b{array-displacement} returns a @i{non-nil}
 
1508
@i{primary value} for any other @i{array}.
 
1509
 
 
1510
@subsubheading  Examples::
 
1511
 
 
1512
@example
 
1513
 (setq a1 (make-array 5)) @result{}  #<ARRAY 5 simple 46115576>
 
1514
 (setq a2 (make-array 4 :displaced-to a1
 
1515
                        :displaced-index-offset 1))
 
1516
@result{}  #<ARRAY 4 indirect 46117134>
 
1517
 (array-displacement a2)
 
1518
@result{}  #<ARRAY 5 simple 46115576>, 1
 
1519
 (setq a3 (make-array 2 :displaced-to a2
 
1520
                        :displaced-index-offset 2))
 
1521
@result{}  #<ARRAY 2 indirect 46122527>
 
1522
 (array-displacement a3)
 
1523
@result{}  #<ARRAY 4 indirect 46117134>, 2
 
1524
@end example
 
1525
 
 
1526
@subsubheading  Exceptional Situations::
 
1527
 
 
1528
Should signal an error of @i{type} @b{type-error}
 
1529
                              if @i{array} is not an @i{array}.
 
1530
 
 
1531
@subsubheading  See Also::
 
1532
 
 
1533
@ref{make-array}
 
1534
 
 
1535
@node array-in-bounds-p, array-rank, array-displacement, Arrays Dictionary
 
1536
@subsection array-in-bounds-p                                                [Function]
 
1537
 
 
1538
@code{array-in-bounds-p}  @i{array @r{&rest} subscripts} @result{}  @i{generalized-boolean}
 
1539
 
 
1540
@subsubheading  Arguments and Values::
 
1541
 
 
1542
@i{array}---an @i{array}.
 
1543
 
 
1544
@i{subscripts}---a list of @i{integers} 
 
1545
                     of length equal to the @i{rank} of the @i{array}.
 
1546
 
 
1547
@i{generalized-boolean}---a @i{generalized boolean}.
 
1548
 
 
1549
@subsubheading  Description::
 
1550
 
 
1551
Returns @i{true} if the @i{subscripts} are all in bounds for @i{array};
 
1552
otherwise returns @i{false}.
 
1553
(If @i{array} is a @i{vector} with a @i{fill pointer}, 
 
1554
 that @i{fill pointer} is ignored.)
 
1555
 
 
1556
@subsubheading  Examples::
 
1557
@example
 
1558
 (setq a (make-array '(7 11) :element-type 'string-char))
 
1559
 (array-in-bounds-p a 0  0) @result{}  @i{true}
 
1560
 (array-in-bounds-p a 6 10) @result{}  @i{true}
 
1561
 (array-in-bounds-p a 0 -1) @result{}  @i{false}
 
1562
 (array-in-bounds-p a 0 11) @result{}  @i{false}
 
1563
 (array-in-bounds-p a 7  0) @result{}  @i{false}
 
1564
@end example
 
1565
 
 
1566
@subsubheading  See Also::
 
1567
 
 
1568
@ref{array-dimensions}
 
1569
 
 
1570
@subsubheading  Notes::
 
1571
@example
 
1572
 (array-in-bounds-p array subscripts)   
 
1573
 @equiv{} (and (not (some #'minusp (list subscripts)))
 
1574
         (every #'< (list subscripts) (array-dimensions array)))
 
1575
@end example
 
1576
 
 
1577
@node array-rank, array-row-major-index, array-in-bounds-p, Arrays Dictionary
 
1578
@subsection array-rank                                                       [Function]
 
1579
 
 
1580
@code{array-rank}  @i{array} @result{}  @i{rank}
 
1581
 
 
1582
@subsubheading  Arguments and Values::
 
1583
 
 
1584
@i{array}---an @i{array}.
 
1585
 
 
1586
@i{rank}---a non-negative @i{integer}.
 
1587
 
 
1588
@subsubheading  Description::
 
1589
 
 
1590
Returns the number of @i{dimensions} of @i{array}.
 
1591
 
 
1592
@subsubheading  Examples::
 
1593
 
 
1594
@example
 
1595
 (array-rank (make-array '())) @result{}  0
 
1596
 (array-rank (make-array 4)) @result{}  1
 
1597
 (array-rank (make-array '(4))) @result{}  1
 
1598
 (array-rank (make-array '(2 3))) @result{}  2
 
1599
@end example
 
1600
 
 
1601
@subsubheading  Exceptional Situations::
 
1602
 
 
1603
Should signal an error of @i{type} @b{type-error} if its argument is not an @i{array}.
 
1604
 
 
1605
@subsubheading  See Also::
 
1606
 
 
1607
@ref{array-rank-limit}
 
1608
 
1609
@ref{make-array}
 
1610
 
 
1611
@node array-row-major-index, array-total-size, array-rank, Arrays Dictionary
 
1612
@subsection array-row-major-index                                            [Function]
 
1613
 
 
1614
@code{array-row-major-index}  @i{array @r{&rest} subscripts} @result{}  @i{index}
 
1615
 
 
1616
@subsubheading  Arguments and Values::
 
1617
 
 
1618
@i{array}---an @i{array}.
 
1619
 
 
1620
@i{subscripts}---a @i{list} of @i{valid array indices} for the @i{array}.
 
1621
 
 
1622
@i{index}---a @i{valid array row-major index} for the @i{array}.
 
1623
 
 
1624
@subsubheading  Description::
 
1625
 
 
1626
Computes the position according to the row-major ordering of @i{array}
 
1627
for the element that is specified by @i{subscripts}, and returns the
 
1628
offset of the element in the computed position from the beginning of @i{array}.
 
1629
 
 
1630
For a one-dimensional @i{array}, 
 
1631
the result of @b{array-row-major-index}
 
1632
equals @i{subscript}.
 
1633
 
 
1634
@b{array-row-major-index} ignores @i{fill pointers}.
 
1635
 
 
1636
@subsubheading  Examples::
 
1637
 
 
1638
@example
 
1639
 (setq a (make-array '(4 7) :element-type '(unsigned-byte 8)))
 
1640
 (array-row-major-index a 1 2) @result{}  9
 
1641
 (array-row-major-index 
 
1642
    (make-array '(2 3 4) 
 
1643
                :element-type '(unsigned-byte 8)
 
1644
                :displaced-to a
 
1645
                :displaced-index-offset 4)
 
1646
    0 2 1) @result{}  9
 
1647
@end example
 
1648
 
 
1649
@subsubheading  Notes::
 
1650
 
 
1651
A possible definition of @b{array-row-major-index}, 
 
1652
with no error-checking, is
 
1653
 
 
1654
@example
 
1655
 (defun array-row-major-index (a &rest subscripts)
 
1656
   (apply #'+ (maplist #'(lambda (x y)
 
1657
                            (* (car x) (apply #'* (cdr y))))
 
1658
                       subscripts
 
1659
                       (array-dimensions a))))
 
1660
@end example
 
1661
 
 
1662
@node array-total-size, arrayp, array-row-major-index, Arrays Dictionary
 
1663
@subsection array-total-size                                                 [Function]
 
1664
 
 
1665
@code{array-total-size}  @i{array} @result{}  @i{size}
 
1666
 
 
1667
@subsubheading  Arguments and Values::
 
1668
 
 
1669
@i{array}---an @i{array}.
 
1670
 
 
1671
@i{size}---a non-negative @i{integer}.
 
1672
 
 
1673
@subsubheading  Description::
 
1674
 
 
1675
Returns the @i{array total size} of the @i{array}.
 
1676
 
 
1677
@subsubheading  Examples::
 
1678
 
 
1679
@example
 
1680
 (array-total-size (make-array 4)) @result{}  4
 
1681
 (array-total-size (make-array 4 :fill-pointer 2)) @result{}  4
 
1682
 (array-total-size (make-array 0)) @result{}  0
 
1683
 (array-total-size (make-array '(4 2))) @result{}  8
 
1684
 (array-total-size (make-array '(4 0))) @result{}  0
 
1685
 (array-total-size (make-array '())) @result{}  1
 
1686
@end example
 
1687
 
 
1688
@subsubheading  Exceptional Situations::
 
1689
 
 
1690
Should signal an error of @i{type} @b{type-error} if its argument is not an @i{array}.
 
1691
 
 
1692
@subsubheading  See Also::
 
1693
 
 
1694
@ref{make-array}
 
1695
 
1696
@ref{array-dimensions}
 
1697
 
 
1698
@subsubheading  Notes::
 
1699
 
 
1700
If the @i{array} is a @i{vector} with a @i{fill pointer},
 
1701
the @i{fill pointer} is ignored when calculating the @i{array total size}.
 
1702
 
 
1703
Since the product of no arguments is one, the @i{array total size} of a
 
1704
zero-dimensional @i{array} is one.
 
1705
 
 
1706
@example
 
1707
 (array-total-size x)
 
1708
    @equiv{} (apply #'* (array-dimensions x))
 
1709
    @equiv{} (reduce #'* (array-dimensions x))
 
1710
@end example
 
1711
 
 
1712
@node arrayp, fill-pointer, array-total-size, Arrays Dictionary
 
1713
@subsection arrayp                                                           [Function]
 
1714
 
 
1715
@code{arrayp}  @i{object} @result{}  @i{generalized-boolean}
 
1716
 
 
1717
@subsubheading  Arguments and Values::
 
1718
 
 
1719
@i{object}---an @i{object}.
 
1720
 
 
1721
@i{generalized-boolean}---a @i{generalized boolean}.
 
1722
 
 
1723
@subsubheading  Description::
 
1724
 
 
1725
Returns @i{true} if @i{object} is of @i{type} @b{array};
 
1726
otherwise, returns @i{false}.
 
1727
 
 
1728
@subsubheading  Examples::
 
1729
 
 
1730
@example
 
1731
 (arrayp (make-array '(2 3 4) :adjustable t)) @result{}  @i{true}
 
1732
 (arrayp (make-array 6)) @result{}  @i{true}
 
1733
 (arrayp #*1011) @result{}  @i{true}
 
1734
 (arrayp "hi") @result{}  @i{true}
 
1735
 (arrayp 'hi) @result{}  @i{false}
 
1736
 (arrayp 12) @result{}  @i{false}
 
1737
@end example
 
1738
 
 
1739
@subsubheading  See Also::
 
1740
 
 
1741
@ref{typep}
 
1742
 
 
1743
@subsubheading  Notes::
 
1744
 
 
1745
@example
 
1746
 (arrayp @i{object}) @equiv{} (typep @i{object} 'array)
 
1747
@end example
 
1748
 
 
1749
@node fill-pointer, row-major-aref, arrayp, Arrays Dictionary
 
1750
@subsection fill-pointer                                                     [Accessor]
 
1751
 
 
1752
@code{fill-pointer}  @i{vector} @result{}  @i{fill-pointer}
 
1753
 
 
1754
(setf (@code{         fill-pointer} @i{vector}) new-fill-pointer)@*
 
1755
 
 
1756
@subsubheading  Arguments and Values::
 
1757
 
 
1758
@i{vector}---a @i{vector} with a @i{fill pointer}.
 
1759
 
 
1760
@i{fill-pointer}, @i{new-fill-pointer}---a @i{valid fill pointer} 
 
1761
  for the @i{vector}.
 
1762
 
 
1763
@subsubheading  Description::
 
1764
 
 
1765
@i{Accesses} the @i{fill pointer} of @i{vector}.
 
1766
 
 
1767
@subsubheading  Examples::
 
1768
 
 
1769
@example
 
1770
 (setq a (make-array 8 :fill-pointer 4)) @result{}  #(NIL NIL NIL NIL)
 
1771
 (fill-pointer a) @result{}  4
 
1772
 (dotimes (i (length a)) (setf (aref a i) (* i i))) @result{}  NIL
 
1773
 a @result{}  #(0 1 4 9)
 
1774
 (setf (fill-pointer a) 3) @result{}  3
 
1775
 (fill-pointer a) @result{}  3
 
1776
 a @result{}  #(0 1 4)
 
1777
 (setf (fill-pointer a) 8) @result{}  8
 
1778
 a @result{}  #(0 1 4 9 NIL NIL NIL NIL)
 
1779
@end example
 
1780
 
 
1781
@subsubheading  Exceptional Situations::
 
1782
 
 
1783
Should signal an error of @i{type} @b{type-error}
 
1784
                              if @i{vector} is not a @i{vector} with a @i{fill pointer}.
 
1785
 
 
1786
@subsubheading  See Also::
 
1787
 
 
1788
@ref{make-array}
 
1789
 
1790
@ref{length}
 
1791
 
 
1792
@subsubheading  Notes::
 
1793
 
 
1794
There is no @i{operator} that will remove a @i{vector}'s @i{fill pointer}.
 
1795
 
 
1796
@node row-major-aref, upgraded-array-element-type, fill-pointer, Arrays Dictionary
 
1797
@subsection row-major-aref                                                   [Accessor]
 
1798
 
 
1799
@code{row-major-aref}  @i{array index} @result{}  @i{element}
 
1800
 
 
1801
(setf (@code{         row-major-aref} @i{array index}) new-element)@*
 
1802
 
 
1803
@subsubheading  Arguments and Values::
 
1804
 
 
1805
@i{array}---an @i{array}.
 
1806
 
 
1807
@i{index}---a @i{valid array row-major index} for the @i{array}.
 
1808
 
 
1809
@i{element}, @i{new-element}---an @i{object}.
 
1810
 
 
1811
@subsubheading  Description::
 
1812
 
 
1813
Considers @i{array} as a @i{vector} by viewing its @i{elements}
 
1814
in row-major order, and returns the @i{element} of that @i{vector} 
 
1815
which is referred to by the given @i{index}.
 
1816
 
 
1817
@b{row-major-aref} is valid for use with @b{setf}.
 
1818
 
 
1819
@subsubheading  See Also::
 
1820
 
 
1821
@ref{aref}
 
1822
,
 
1823
@ref{array-row-major-index}
 
1824
 
 
1825
@subsubheading  Notes::
 
1826
 
 
1827
@example
 
1828
 (row-major-aref array index) @equiv{}
 
1829
   (aref (make-array (array-total-size array)
 
1830
                     :displaced-to array
 
1831
                     :element-type (array-element-type array))
 
1832
         index)
 
1833
 
 
1834
 (aref array i1 i2 ...) @equiv{}
 
1835
     (row-major-aref array (array-row-major-index array i1 i2))
 
1836
@end example
 
1837
 
 
1838
@node upgraded-array-element-type, array-dimension-limit, row-major-aref, Arrays Dictionary
 
1839
@subsection upgraded-array-element-type                                      [Function]
 
1840
 
 
1841
@code{upgraded-array-element-type}  @i{typespec @r{&optional} environment} @result{}  @i{upgraded-typespec}
 
1842
 
 
1843
@subsubheading  Arguments and Values::
 
1844
 
 
1845
@i{typespec}---a @i{type specifier}.
 
1846
 
 
1847
@i{environment}---an @i{environment} @i{object}.
 
1848
  The default is @b{nil}, denoting the @i{null lexical environment}
 
1849
           and the current @i{global environment}.
 
1850
 
 
1851
@i{upgraded-typespec}---a @i{type specifier}.
 
1852
 
 
1853
@subsubheading  Description::
 
1854
 
 
1855
Returns the @i{element type} of 
 
1856
the most @i{specialized} @i{array} representation capable of 
 
1857
holding items of the @i{type} denoted by @i{typespec}.
 
1858
 
 
1859
The @i{typespec} is a @i{subtype} of 
 
1860
(and possibly @i{type equivalent} to)
 
1861
the @i{upgraded-typespec}.
 
1862
 
 
1863
If @i{typespec} is @b{bit},
 
1864
 the result is @i{type equivalent} to @t{bit}.
 
1865
 
 
1866
If @i{typespec} is @b{base-char},
 
1867
 the result is @i{type equivalent} to @t{base-char}.
 
1868
 
 
1869
If @i{typespec} is @b{character},
 
1870
 the result is @i{type equivalent} to @t{character}.
 
1871
 
 
1872
The purpose of @b{upgraded-array-element-type} is to reveal how
 
1873
an implementation does its @i{upgrading}.
 
1874
 
 
1875
The @i{environment} is used to expand any @i{derived type specifiers}
 
1876
that are mentioned in the @i{typespec}.
 
1877
 
 
1878
@subsubheading  See Also::
 
1879
 
 
1880
@ref{array-element-type}
 
1881
,
 
1882
@ref{make-array}
 
1883
 
 
1884
@subsubheading  Notes::
 
1885
 
 
1886
Except for storage allocation consequences and dealing correctly with the
 
1887
optional @i{environment} @i{argument},
 
1888
@b{upgraded-array-element-type} could be defined as:
 
1889
 
 
1890
@example
 
1891
 (defun upgraded-array-element-type (type &optional environment)
 
1892
   (array-element-type (make-array 0 :element-type type)))
 
1893
@end example
 
1894
 
 
1895
@node array-dimension-limit, array-rank-limit, upgraded-array-element-type, Arrays Dictionary
 
1896
@subsection array-dimension-limit                                   [Constant Variable]
 
1897
 
 
1898
@subsubheading  Constant Value::
 
1899
 
 
1900
A positive
 
1901
 
 
1902
@i{fixnum},
 
1903
 
 
1904
the exact magnitude of which is @i{implementation-dependent},
 
1905
but which is not less than @t{1024}.
 
1906
 
 
1907
@subsubheading  Description::
 
1908
 
 
1909
The upper exclusive bound on each individual @i{dimension} of an @i{array}.
 
1910
 
 
1911
@subsubheading  See Also::
 
1912
 
 
1913
@ref{make-array}
 
1914
 
 
1915
@node array-rank-limit, array-total-size-limit, array-dimension-limit, Arrays Dictionary
 
1916
@subsection array-rank-limit                                        [Constant Variable]
 
1917
 
 
1918
@subsubheading  Constant Value::
 
1919
 
 
1920
A positive
 
1921
 
 
1922
@i{fixnum},
 
1923
 
 
1924
the exact magnitude of which is @i{implementation-dependent},
 
1925
but which is not less than @t{8}.
 
1926
 
 
1927
@subsubheading  Description::
 
1928
 
 
1929
The upper exclusive bound on the @i{rank} of an @i{array}.
 
1930
 
 
1931
@subsubheading  See Also::
 
1932
 
 
1933
@ref{make-array}
 
1934
 
 
1935
@node array-total-size-limit, simple-vector-p, array-rank-limit, Arrays Dictionary
 
1936
@subsection array-total-size-limit                                  [Constant Variable]
 
1937
 
 
1938
@subsubheading  Constant Value::
 
1939
 
 
1940
A positive
 
1941
 
 
1942
@i{fixnum},
 
1943
 
 
1944
the exact magnitude of which is @i{implementation-dependent},
 
1945
but which is not less than @t{1024}.
 
1946
 
 
1947
@subsubheading  Description::
 
1948
 
 
1949
The upper exclusive bound on the @i{array total size} of an @i{array}.
 
1950
 
 
1951
The actual limit on the @i{array total size} 
 
1952
imposed by the @i{implementation}
 
1953
might vary according the @i{element type} of the @i{array};
 
1954
in this case, the value of @b{array-total-size-limit} 
 
1955
will be the smallest of these possible limits.
 
1956
 
 
1957
@subsubheading  See Also::
 
1958
 
 
1959
@ref{make-array}
 
1960
 
1961
@ref{array-element-type}
 
1962
 
 
1963
@node simple-vector-p, svref, array-total-size-limit, Arrays Dictionary
 
1964
@subsection simple-vector-p                                                  [Function]
 
1965
 
 
1966
@code{simple-vector-p}  @i{object} @result{}  @i{generalized-boolean}
 
1967
 
 
1968
@subsubheading  Arguments and Values::
 
1969
 
 
1970
@i{object}---an @i{object}.
 
1971
 
 
1972
@i{generalized-boolean}---a @i{generalized boolean}.
 
1973
 
 
1974
@subsubheading  Description::
 
1975
 
 
1976
Returns @i{true} if @i{object} is of @i{type} @b{simple-vector};
 
1977
otherwise, returns @i{false}..
 
1978
 
 
1979
@subsubheading  Examples::        
 
1980
 
 
1981
@example
 
1982
 (simple-vector-p (make-array 6)) @result{}  @i{true}
 
1983
 (simple-vector-p "aaaaaa") @result{}  @i{false}
 
1984
 (simple-vector-p (make-array 6 :fill-pointer t)) @result{}  @i{false}
 
1985
@end example
 
1986
 
 
1987
@subsubheading  See Also:: 
 
1988
 
 
1989
@b{simple-vector}
 
1990
 
 
1991
@subsubheading  Notes::
 
1992
 
 
1993
@example
 
1994
 (simple-vector-p @i{object}) @equiv{} (typep @i{object} 'simple-vector)
 
1995
@end example
 
1996
 
 
1997
@node svref, vector, simple-vector-p, Arrays Dictionary
 
1998
@subsection svref                                                            [Accessor]
 
1999
 
 
2000
@code{svref}  @i{simple-vector index} @result{}  @i{element}
 
2001
 
 
2002
(setf (@code{         svref} @i{simple-vector index}) new-element)@*
 
2003
 
 
2004
@subsubheading  Arguments and Values::
 
2005
 
 
2006
@i{simple-vector}---a @i{simple vector}.
 
2007
 
 
2008
@i{index}---a @i{valid array index} for the @i{simple-vector}.
 
2009
 
 
2010
@i{element}, @i{new-element}---an @i{object}
 
2011
  (whose @i{type} is a @i{subtype} 
 
2012
   of the @i{array element type} of the @i{simple-vector}).
 
2013
 
 
2014
@subsubheading  Description::
 
2015
 
 
2016
@i{Accesses} the @i{element} of @i{simple-vector} specified by @i{index}.
 
2017
 
 
2018
@subsubheading  Examples::
 
2019
 
 
2020
@example
 
2021
 (simple-vector-p (setq v (vector 1 2 'sirens))) @result{}  @i{true}
 
2022
 (svref v 0) @result{}  1
 
2023
 (svref v 2) @result{}  SIRENS
 
2024
 (setf (svref v 1) 'newcomer) @result{}  NEWCOMER               
 
2025
 v @result{}  #(1 NEWCOMER SIRENS)
 
2026
@end example
 
2027
 
 
2028
@subsubheading  See Also::
 
2029
 
 
2030
@ref{aref}
 
2031
,
 
2032
@b{sbit},
 
2033
@b{schar},
 
2034
@ref{vector}
 
2035
,
 
2036
 
 
2037
@ref{Compiler Terminology}
 
2038
 
 
2039
@subsubheading  Notes::
 
2040
 
 
2041
@b{svref} is identical to @b{aref} 
 
2042
except that it requires its first argument to be a @i{simple vector}.  
 
2043
 
 
2044
@example
 
2045
 (svref @i{v} @i{i}) @equiv{} (aref (the simple-vector @i{v}) @i{i})
 
2046
@end example
 
2047
 
 
2048
@node vector, vector-pop, svref, Arrays Dictionary
 
2049
@subsection vector                                                           [Function]
 
2050
 
 
2051
@code{vector}  @i{@r{&rest} objects} @result{}  @i{vector}
 
2052
 
 
2053
@subsubheading  Arguments and Values:: 
 
2054
 
 
2055
@i{object}---an @i{object}.
 
2056
 
 
2057
@i{vector}---a @i{vector} of @i{type} @t{(vector t @t{*})}.
 
2058
 
 
2059
@subsubheading  Description::
 
2060
 
 
2061
Creates a @i{fresh} @i{simple general vector} whose size
 
2062
corresponds to the number of @i{objects}. 
 
2063
 
 
2064
The @i{vector} is initialized to contain the @i{objects}.
 
2065
 
 
2066
@subsubheading  Examples::
 
2067
 
 
2068
@example
 
2069
 (arrayp (setq v (vector 1 2 'sirens))) @result{}  @i{true}
 
2070
 (vectorp v) @result{}  @i{true}
 
2071
 (simple-vector-p v) @result{}  @i{true}         
 
2072
 (length v) @result{}  3
 
2073
@end example
 
2074
 
 
2075
@subsubheading  See Also::
 
2076
 
 
2077
@ref{make-array}
 
2078
 
 
2079
@subsubheading  Notes::
 
2080
 
 
2081
@b{vector} is analogous to @b{list}.
 
2082
 
 
2083
@example
 
2084
 (vector a_1 a_2 ... a_n)
 
2085
  @equiv{} (make-array (list @i{n}) :element-type t
 
2086
                          :initial-contents 
 
2087
                            (list a_1 a_2 ... a_n))
 
2088
@end example
 
2089
 
 
2090
@node vector-pop, vector-push, vector, Arrays Dictionary
 
2091
@subsection vector-pop                                                       [Function]
 
2092
 
 
2093
@code{vector-pop}  @i{vector} @result{}  @i{element}
 
2094
 
 
2095
@subsubheading  Arguments and Values::
 
2096
 
 
2097
@i{vector}---a @i{vector} with a @i{fill pointer}.
 
2098
 
 
2099
@i{element}---an @i{object}.
 
2100
 
 
2101
@subsubheading  Description::
 
2102
 
 
2103
Decreases the @i{fill pointer} of @i{vector} by one, 
 
2104
and retrieves the @i{element} of @i{vector} that is
 
2105
designated by the new @i{fill pointer}.
 
2106
 
 
2107
@subsubheading  Examples::
 
2108
 
 
2109
@example
 
2110
 (vector-push (setq fable (list 'fable))
 
2111
              (setq fa (make-array 8
 
2112
                                   :fill-pointer 2
 
2113
                                   :initial-element 'sisyphus))) @result{}  2 
 
2114
 (fill-pointer fa) @result{}  3 
 
2115
 (eq (vector-pop fa) fable) @result{}  @i{true}
 
2116
 (vector-pop fa) @result{}  SISYPHUS 
 
2117
 (fill-pointer fa) @result{}  1 
 
2118
@end example
 
2119
 
 
2120
@subsubheading  Side Effects::
 
2121
 
 
2122
The @i{fill pointer} is decreased by one.
 
2123
 
 
2124
@subsubheading  Affected By::
 
2125
 
 
2126
The value of the @i{fill pointer}.
 
2127
 
 
2128
@subsubheading  Exceptional Situations::
 
2129
 
 
2130
An error of @i{type} @b{type-error} is signaled if @i{vector} does not have a @i{fill pointer}.
 
2131
 
 
2132
If the @i{fill pointer} is zero, @b{vector-pop} signals an error of @i{type} @b{error}.
 
2133
 
 
2134
@subsubheading  See Also::
 
2135
 
 
2136
@ref{vector-push}
 
2137
, @b{vector-push-extend}, 
 
2138
@ref{fill-pointer}
 
2139
 
 
2140
@node vector-push, vectorp, vector-pop, Arrays Dictionary
 
2141
@subsection vector-push, vector-push-extend                                  [Function]
 
2142
 
 
2143
@code{vector-push}  @i{new-element vector} @result{}  @i{new-index-p}
 
2144
 
 
2145
@code{vector-push-extend}  @i{new-element vector @r{&optional} extension} @result{}  @i{new-index}
 
2146
 
 
2147
@subsubheading  Arguments and Values::
 
2148
 
 
2149
@i{new-element}---an @i{object}.
 
2150
 
 
2151
@i{vector}---a @i{vector} with a @i{fill pointer}.
 
2152
 
 
2153
@i{extension}---a positive @i{integer}.
 
2154
 The default is @i{implementation-dependent}.
 
2155
 
 
2156
@i{new-index-p}---a @i{valid array index} for @i{vector}, or @b{nil}.
 
2157
 
 
2158
@i{new-index}---a @i{valid array index} for @i{vector}.
 
2159
 
 
2160
@subsubheading  Description::
 
2161
 
 
2162
@b{vector-push} and @b{vector-push-extend} store 
 
2163
@i{new-element} in @i{vector}.
 
2164
@b{vector-push} attempts to store
 
2165
@i{new-element} 
 
2166
in the element of @i{vector} designated by the @i{fill pointer},
 
2167
and to increase the @i{fill pointer} by one.  If the 
 
2168
@t{(>= (fill-pointer @i{vector}) (array-dimension @i{vector} 0))},
 
2169
neither @i{vector} nor its @i{fill pointer} are affected.
 
2170
Otherwise, the store and increment take
 
2171
place and @b{vector-push} 
 
2172
returns the former value of the @i{fill pointer}
 
2173
which is one less than the one it leaves in @i{vector}.
 
2174
 
 
2175
@b{vector-push-extend} is just like @b{vector-push} except
 
2176
that if the @i{fill pointer} gets too large, @i{vector} is extended using
 
2177
@b{adjust-array} so that it can contain more elements.
 
2178
@i{Extension}
 
2179
is the minimum number of elements to be added to @i{vector} if it
 
2180
must be extended.
 
2181
 
 
2182
@b{vector-push} and 
 
2183
@b{vector-push-extend} return the index of @i{new-element} in @i{vector}.
 
2184
If @t{(>= (fill-pointer @i{vector}) (array-dimension @i{vector} 0))},
 
2185
@b{vector-push} returns @b{nil}.
 
2186
 
 
2187
@subsubheading  Examples::
 
2188
 
 
2189
@example
 
2190
 (vector-push (setq fable (list 'fable))
 
2191
              (setq fa (make-array 8 
 
2192
                                   :fill-pointer 2
 
2193
                                   :initial-element 'first-one))) @result{}  2 
 
2194
 (fill-pointer fa) @result{}  3 
 
2195
 (eq (aref fa 2) fable) @result{}  @i{true}
 
2196
 (vector-push-extend #\X
 
2197
                    (setq aa 
 
2198
                          (make-array 5
 
2199
                                      :element-type 'character
 
2200
                                      :adjustable t
 
2201
                                      :fill-pointer 3))) @result{}  3 
 
2202
 (fill-pointer aa) @result{}  4 
 
2203
 (vector-push-extend #\Y aa 4) @result{}  4 
 
2204
 (array-total-size aa) @result{}  at least 5 
 
2205
 (vector-push-extend #\Z aa 4) @result{}  5 
 
2206
 (array-total-size aa) @result{}  9 ;(or more)
 
2207
@end example
 
2208
 
 
2209
@subsubheading  Affected By::
 
2210
The value of the @i{fill pointer}.
 
2211
 
 
2212
How @i{vector} was created.
 
2213
 
 
2214
@subsubheading  Exceptional Situations::         
 
2215
 
 
2216
An error of @i{type} @b{error} is signaled by @b{vector-push-extend}
 
2217
if it tries to extend @i{vector} and @i{vector} is not @i{actually adjustable}.
 
2218
 
 
2219
An error of @i{type} @b{error} is signaled if @i{vector} does not 
 
2220
have a @i{fill pointer}.
 
2221
 
 
2222
@subsubheading  See Also::
 
2223
 
 
2224
@ref{adjustable-array-p}
 
2225
 
2226
@ref{fill-pointer}
 
2227
 
2228
@ref{vector-pop}
 
2229
 
 
2230
@node vectorp, bit (Array), vector-push, Arrays Dictionary
 
2231
@subsection vectorp                                                          [Function]
 
2232
 
 
2233
@code{vectorp}  @i{object} @result{}  @i{generalized-boolean}
 
2234
 
 
2235
@subsubheading  Arguments and Values::
 
2236
 
 
2237
@i{object}---an @i{object}.
 
2238
 
 
2239
@i{generalized-boolean}---a @i{generalized boolean}.
 
2240
 
 
2241
@subsubheading  Description::
 
2242
 
 
2243
Returns @i{true} if @i{object} is of @i{type} @b{vector};
 
2244
otherwise, returns @i{false}.
 
2245
 
 
2246
@subsubheading  Examples::
 
2247
 
 
2248
@example
 
2249
 (vectorp "aaaaaa") @result{}  @i{true}
 
2250
 (vectorp (make-array 6 :fill-pointer t)) @result{}  @i{true}
 
2251
 (vectorp (make-array '(2 3 4))) @result{}  @i{false}
 
2252
 (vectorp #*11) @result{}  @i{true}
 
2253
 (vectorp #b11) @result{}  @i{false}
 
2254
@end example
 
2255
 
 
2256
@subsubheading  Notes::
 
2257
@example
 
2258
 (vectorp @i{object}) @equiv{} (typep @i{object} 'vector)
 
2259
@end example
 
2260
 
 
2261
@node bit (Array), bit-and, vectorp, Arrays Dictionary
 
2262
@subsection bit, sbit                                                        [Accessor]
 
2263
 
 
2264
@code{bit}  @i{bit-array @r{&rest} subscripts} @result{}  @i{bit}
 
2265
 
 
2266
@code{sbit}  @i{bit-array @r{&rest} subscripts} @result{}  @i{bit}
 
2267
 
 
2268
(setf (@code{bit} @i{bit-array @r{&rest} subscripts}) new-bit)@*(setf (@code{sbit} @i{bit-array @r{&rest} subscripts}) new-bit)@*
 
2269
 
 
2270
@subsubheading  Arguments and Values::
 
2271
 
 
2272
@i{bit-array}---for @b{bit},  a @i{bit array};
 
2273
                    for @b{sbit}, a @i{simple bit array}.
 
2274
 
 
2275
@i{subscripts}---a @i{list} of @i{valid array indices} 
 
2276
                     for the @i{bit-array}.
 
2277
 
 
2278
@i{bit}---a @i{bit}.
 
2279
 
 
2280
@subsubheading  Description::
 
2281
 
 
2282
@b{bit} and @b{sbit} @i{access} the @i{bit-array} 
 
2283
@i{element} specified by @i{subscripts}.
 
2284
 
 
2285
These @i{functions} ignore the @i{fill pointer} when @i{accessing} @i{elements}.
 
2286
 
 
2287
@subsubheading  Examples::
 
2288
 
 
2289
@example
 
2290
 (bit (setq ba (make-array 8 
 
2291
                            :element-type 'bit 
 
2292
                            :initial-element 1))
 
2293
       3) @result{}  1
 
2294
 (setf (bit ba 3) 0) @result{}  0
 
2295
 (bit ba 3) @result{}  0
 
2296
 (sbit ba 5) @result{}  1
 
2297
 (setf (sbit ba 5) 1) @result{}  1
 
2298
 (sbit ba 5) @result{}  1
 
2299
@end example
 
2300
 
 
2301
@subsubheading  See Also::
 
2302
 
 
2303
@ref{aref}
 
2304
,
 
2305
 
 
2306
@ref{Compiler Terminology}
 
2307
 
 
2308
@subsubheading  Notes::
 
2309
 
 
2310
@b{bit} and @b{sbit} are like @b{aref}
 
2311
except that they require @i{arrays} to be
 
2312
a @i{bit array} and a @i{simple bit array}, respectively.
 
2313
 
 
2314
@b{bit} and @b{sbit}, unlike @b{char} and @b{schar},
 
2315
allow the first argument to be an @i{array} of any @i{rank}.
 
2316
 
 
2317
@node bit-and, bit-vector-p, bit (Array), Arrays Dictionary
 
2318
@subsection bit-and, bit-andc1, bit-andc2, bit-eqv,
 
2319
@subheading bit-ior, bit-nand, bit-nor, bit-not, bit-orc1, bit-orc2, bit-xor
 
2320
@flushright
 
2321
@i{[Function]}
 
2322
@end flushright
 
2323
 
 
2324
@code{bit-and}  @i{bit-array1 bit-array2 @r{&optional} opt-arg} @result{}  @i{resulting-bit-array}
 
2325
 
 
2326
@code{bit-andc1}  @i{bit-array1 bit-array2 @r{&optional} opt-arg} @result{}  @i{resulting-bit-array}
 
2327
 
 
2328
@code{bit-andc2}  @i{bit-array1 bit-array2 @r{&optional} opt-arg} @result{}  @i{resulting-bit-array}
 
2329
 
 
2330
@code{bit-eqv}  @i{bit-array1 bit-array2 @r{&optional} opt-arg} @result{}  @i{resulting-bit-array}
 
2331
 
 
2332
@code{bit-ior}  @i{bit-array1 bit-array2 @r{&optional} opt-arg} @result{}  @i{resulting-bit-array}
 
2333
 
 
2334
@code{bit-nand}  @i{bit-array1 bit-array2 @r{&optional} opt-arg} @result{}  @i{resulting-bit-array}
 
2335
 
 
2336
@code{bit-nor}  @i{bit-array1 bit-array2 @r{&optional} opt-arg} @result{}  @i{resulting-bit-array}
 
2337
 
 
2338
@code{bit-orc1}  @i{bit-array1 bit-array2 @r{&optional} opt-arg} @result{}  @i{resulting-bit-array}
 
2339
 
 
2340
@code{bit-orc2}  @i{bit-array1 bit-array2 @r{&optional} opt-arg} @result{}  @i{resulting-bit-array}
 
2341
 
 
2342
@code{bit-xor}  @i{bit-array1 bit-array2 @r{&optional} opt-arg} @result{}  @i{resulting-bit-array}
 
2343
 
 
2344
@code{bit-not}  @i{bit-array @r{&optional} opt-arg} @result{}  @i{resulting-bit-array}
 
2345
 
 
2346
@subsubheading  Arguments and Values::
 
2347
 
 
2348
@i{bit-array}, @i{bit-array1}, @i{bit-array2}---a @i{bit array}.
 
2349
 
 
2350
@i{Opt-arg}---a @i{bit array}, or @b{t}, or @b{nil}.
 
2351
 The default is @b{nil}.
 
2352
 
 
2353
@i{Bit-array}, @i{bit-array1}, @i{bit-array2}, and @i{opt-arg}
 
2354
(if an @i{array}) must all be of the same @i{rank} and @i{dimensions}.  
 
2355
 
 
2356
@i{resulting-bit-array}---a @i{bit array}.
 
2357
 
 
2358
@subsubheading  Description::
 
2359
 
 
2360
These functions perform 
 
2361
bit-wise logical operations on @i{bit-array1} and @i{bit-array2}
 
2362
and return an @i{array} 
 
2363
of matching @i{rank} and @i{dimensions},
 
2364
such that any given bit of the result
 
2365
is produced by operating on corresponding bits from each of the arguments.
 
2366
 
 
2367
In the case of @b{bit-not}, an @i{array}
 
2368
of @i{rank} and @i{dimensions} matching @i{bit-array}
 
2369
is returned that contains a copy of @i{bit-array} 
 
2370
with all the bits inverted.
 
2371
 
 
2372
If @i{opt-arg} is of type @t{(array bit)} the contents of the 
 
2373
result are destructively placed into @i{opt-arg}.
 
2374
If @i{opt-arg} is the symbol @b{t},
 
2375
@i{bit-array} or @i{bit-array1} is replaced with the result; 
 
2376
if @i{opt-arg} is @b{nil} or omitted, a new @i{array} is created
 
2377
to contain the result.  
 
2378
 
 
2379
Figure 15--4 indicates the logical operation
 
2380
performed by each of the @i{functions}.
 
2381
 
 
2382
 2
 
2383
@format
 
2384
@group
 
2385
@noindent
 
2386
@w{@b{Function}                                                   @b{Operation}                                   }
 
2387
@w{_______________________________________________________________________________________________________}
 
2388
@w{                                                           }
 
2389
@w{@b{bit-and}                                                    and                                         }
 
2390
@w{@b{bit-eqv}                                                    equivalence (exclusive nor)                 }
 
2391
@w{@b{bit-not}                                                    complement                                  }
 
2392
@w{@b{bit-ior}                                                    inclusive or                                }
 
2393
@w{@b{bit-xor}                                                    exclusive or                                }
 
2394
@w{@b{bit-nand}                                                   complement of @i{bit-array1} and @i{bit-array2}     }
 
2395
@w{@b{bit-nor}                                                    complement of @i{bit-array1} or @i{bit-array2}      }
 
2396
@w{@b{bit-andc1}                                                  and complement of @i{bit-array1} with @i{bit-array2}}
 
2397
@w{@b{bit-andc2}                                                  and @i{bit-array1} with complement of @i{bit-array2}}
 
2398
@w{@b{bit-orc1}                                                   or complement of @i{bit-array1} with @i{bit-array2} }
 
2399
@w{@b{bit-orc2}                                                   or @i{bit-array1} with complement of @i{bit-array2} }
 
2400
@w{@w{  Figure 15--3: Bit-wise Logical Operations on Bit Arrays}
 
2401
}
 
2402
@end group
 
2403
@end format
 
2404
 
 
2405
@subsubheading  Examples::
 
2406
@example
 
2407
 (bit-and (setq ba #*11101010) #*01101011) @result{}  #*01101010
 
2408
 (bit-and #*1100 #*1010) @result{}  #*1000      
 
2409
 (bit-andc1 #*1100 #*1010) @result{}  #*0010
 
2410
 (setq rba (bit-andc2 ba #*00110011 t)) @result{}  #*11001000
 
2411
 (eq rba ba) @result{}  @i{true}
 
2412
 (bit-not (setq ba #*11101010)) @result{}  #*00010101
 
2413
 (setq rba (bit-not ba 
 
2414
                     (setq tba (make-array 8 
 
2415
                                           :element-type 'bit))))
 
2416
@result{}  #*00010101
 
2417
 (equal rba tba) @result{}  @i{true}
 
2418
 (bit-xor #*1100 #*1010) @result{}  #*0110
 
2419
@end example
 
2420
 
 
2421
@subsubheading  See Also::
 
2422
 
 
2423
@b{lognot}, 
 
2424
@ref{logand}
 
2425
 
 
2426
@node bit-vector-p, simple-bit-vector-p, bit-and, Arrays Dictionary
 
2427
@subsection bit-vector-p                                                     [Function]
 
2428
 
 
2429
@code{bit-vector-p}  @i{object} @result{}  @i{generalized-boolean}
 
2430
 
 
2431
@subsubheading  Arguments and Values::
 
2432
 
 
2433
@i{object}---an @i{object}.
 
2434
 
 
2435
@i{generalized-boolean}---a @i{generalized boolean}.
 
2436
 
 
2437
@subsubheading  Description::
 
2438
 
 
2439
Returns @i{true} if @i{object} is of @i{type} @b{bit-vector};
 
2440
otherwise, returns @i{false}.
 
2441
 
 
2442
@subsubheading  Examples::
 
2443
 
 
2444
@example
 
2445
 (bit-vector-p (make-array 6 
 
2446
                           :element-type 'bit 
 
2447
                           :fill-pointer t)) @result{}  @i{true}
 
2448
 (bit-vector-p #*) @result{}  @i{true}
 
2449
 (bit-vector-p (make-array 6)) @result{}  @i{false}
 
2450
@end example
 
2451
 
 
2452
@subsubheading  See Also::                  
 
2453
 
 
2454
@ref{typep}
 
2455
 
 
2456
@subsubheading  Notes::
 
2457
 
 
2458
@example
 
2459
 (bit-vector-p @i{object}) @equiv{} (typep @i{object} 'bit-vector)
 
2460
@end example
 
2461
 
 
2462
@node simple-bit-vector-p,  , bit-vector-p, Arrays Dictionary
 
2463
@subsection simple-bit-vector-p                                              [Function]
 
2464
 
 
2465
@code{simple-bit-vector-p}  @i{object} @result{}  @i{generalized-boolean}
 
2466
 
 
2467
@subsubheading  Arguments and Values::             
 
2468
 
 
2469
@i{object}---an @i{object}.
 
2470
 
 
2471
@i{generalized-boolean}---a @i{generalized boolean}.
 
2472
 
 
2473
@subsubheading  Description::
 
2474
 
 
2475
Returns @i{true} if @i{object} is of @i{type} @b{simple-bit-vector};
 
2476
otherwise, returns @i{false}.
 
2477
 
 
2478
@subsubheading  Examples::           
 
2479
@example
 
2480
 (simple-bit-vector-p (make-array 6)) @result{}  @i{false}
 
2481
 (simple-bit-vector-p #*) @result{}  @i{true}
 
2482
@end example
 
2483
 
 
2484
@subsubheading  See Also:: 
 
2485
 
 
2486
@ref{simple-vector-p}
 
2487
 
 
2488
@subsubheading  Notes::
 
2489
@example
 
2490
 (simple-bit-vector-p @i{object}) @equiv{} (typep @i{object} 'simple-bit-vector)
 
2491
@end example
 
2492
 
 
2493
@c end of including dict-arrays
 
2494
 
 
2495
@c %**end of chapter
 
2496