User Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

cl:functions:array-displacement [2019/07/14 17:00]
cl:functions:array-displacement [2019/07/18 14:00] (current)
Line 1: Line 1:
 +====== Function ARRAY-DISPLACEMENT ======
 +
 +====Syntax====
 +  * **array-displacement** //array// → //​displaced-to,​ displaced-index-offset//​
 +
 +====Arguments and Values====
 +  * //array// - an //​[[CL:​Glossary:​array]]//​.
 +  * //​displaced-to//​ - an //array// or **[[CL:​Constant Variables:​nil]]**.
 +  * //​displaced-index-offset//​ - a non-negative //​[[CL:​Glossary:​fixnum]]//​.
 +
 +====Description====
 +If the //array// is a //​[[CL:​Glossary:​displaced array]]//, returns the //​[[CL:​Glossary:​values]]//​ of the **'':​displaced-to''​** and **'':​displaced-index-offset''​** options for the //​[[CL:​Glossary:​array]]//​ (see the //​[[CL:​Glossary:​function|functions]]//​ **[[CL:​Functions:​make-array]]** and **[[CL:​Functions:​adjust-array]]**). If the //array// is not a //​[[CL:​Glossary:​displaced array]]//, **[[CL:​Constant Variables:​nil]]** and ''​0''​ are returned.
 +
 +If **array-displacement** is called on an //array// for which a //​[[CL:​Glossary:​non-nil]]//​ //​[[CL:​Glossary:​object]]//​ was provided as the **'':​displaced-to''​** //​[[CL:​Glossary:​argument]]//​ to **[[CL:​Functions:​make-array]]** or **[[CL:​Functions:​adjust-array]]**,​ it must return that //​[[CL:​Glossary:​object]]//​ as its first value. It is //​[[CL:​Glossary:​implementation-dependent]]//​ whether **array-displacement** returns a //​[[CL:​Glossary:​non-nil]]//​ //​[[CL:​Glossary:​primary value]]// for any other //array//.
 +
 +====Examples====
 +
 +<​blockquote>​
 +([[CL:​Macros:​defparameter]] *a1* 
 +  ([[CL:​Functions:​make-array]] 5)) <​r>​*A1*</​r>​
 +([[CL:​Macros:​defparameter]] *a2* 
 +  ([[CL:​Functions:​make-array]] 4 :​displaced-to *a1* 
 +                :​displaced-index-offset 1)) <​r>​*A2*</​r>​
 +(array-displacement *a2*)
 +<​r>#<​ARRAY 5 simple 46115576>​
 +1
 +</r>
 +([[CL:​Macros:​defparameter]] *a3*
 +  ([[CL:​Functions:​make-array]] 2 :​displaced-to *a2* 
 +                :​displaced-index-offset 2)) <​r>​*A3*</​r>​
 +(array-displacement *a3*) 
 +<​r>#<​ARRAY 4 indirect 46117134>​
 +2</​r> ​
 +</​blockquote>​
 +
 +====Affected By====
 +None.
 +
 +====Exceptional Situations====
 +Should signal an error of type type-error if //array// is not an //​[[CL:​Glossary:​array]]//​.
 +
 +====See Also====
 +**[[CL:​Functions:​make-array|Function MAKE-ARRAY]]**
 +
 +====Notes====
 +None.
 +
 +\issue{DISPLACED-ARRAY-PREDICATE:​ADD}