User Tools


Differences

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

Link to this comparison view

cl:functions:length [2019/07/14 17:00]
cl:functions:length [2019/07/18 14:00] (current)
Line 1: Line 1:
 +====== Function LENGTH ======
 +
 +====Syntax====
 +  * **length** //​sequence//​ → //n//
 +
 +====Arguments and Values====
 +  * //​sequence//​ - a //​[[CL:​Glossary:​proper sequence]]//​.
 +  * //n// - a non-negative //​[[CL:​Glossary:​integer]]//​.
 +
 +====Description====
 +Returns the number of //​[[CL:​Glossary:​element|elements]]//​ in //​sequence//​.
 +
 +If //​sequence//​ is a //​[[CL:​Glossary:​vector]]//​ with a //​[[CL:​Glossary:​fill pointer]]//,​ the active length as specified by the //​[[CL:​Glossary:​fill pointer]]// is returned.
 +
 +====Examples====
 +<​blockquote> ​
 +(length "​abc"​) <r>3 </r>
 +([[CL:​Macros:​defparameter]] *str* 
 +  ([[CL:​Functions:​make-array]] '(3) :​element-type '​[[CL:​Types:​character]] ​
 +                   :​initial-contents "​abc" ​
 +                   :​fill-pointer t)) <​r>"​abc"​ </r>
 +(length *str*) <r>3 </r>
 +([[CL:​Macros:​setf]] ([[CL:​Functions:​fill-pointer]] *str*) 2) <r>2 </r>
 +(length *str*) <r>2 </r>
 +</​blockquote>​
 +
 +====Affected By====
 +None.
 +
 +====Exceptional Situations====
 +Should be prepared to signal an error of type type-error if //​sequence//​ is not a //​[[CL:​Glossary:​proper sequence]]//​.
 +
 +====See Also====
 +  * **[[CL:​Functions:​list-length|Function LIST-LENGTH]]**
 +  * **[[CL:​Types:​sequence|System Class SEQUENCE]]**
 +
 +====Notes====
 +None.
 +