User Tools


Differences

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

Link to this comparison view

cl:functions:char [2019/06/15 02:00]
cl:functions:char [2019/08/17 15:00] (current)
Line 1: Line 1:
 +====== Accessor CHAR, SCHAR ======
 +
 +====Syntax====
 +  * **char** //string// //index// → //​character// ​
 +  * **schar** //string// //index// → //​character// ​
 +  * (**setf** (**char** //string// //index//) //​new-character//​)
 +  * (**setf** (**schar** //string// //index//) //​new-character//​)
 +
 +====Arguments and Values====
 +  * //string// - for **char**, a //​[[CL:​Glossary:​string]]//;​ for **schar**, a //​[[CL:​Glossary:​simple string]]//.
 +  * //index// - a //​[[CL:​Glossary:​valid array index]]// for the //string//.
 +  * //​character//,​ //​new-character//​ - a //​[[CL:​Glossary:​character]]//​.
 +
 +====Description====
 +**char** and **schar** //​[[CL:​Glossary:​access]]//​ the //​[[CL:​Glossary:​element]]//​ of //string// specified by //index//.
 +
 +**char** ignores //​[[CL:​Glossary:​fill pointer|fill pointers]]//​ when //​[[CL:​Glossary:​access|accessing]]//​ //​[[CL:​Glossary:​element|elements]]//​.
 +
 +====Examples====
 +<​blockquote> ​
 +([[CL:​Macros:​defparameter]] *my-simple-string* ​
 +  ([[CL:​Functions:​make-string]] 6 :​initial-element #\A)) → "​AAAAAA" ​
 +(schar *my-simple-string* 4) → #\A 
 +([[CL:​Macros:​setf]] (schar *my-simple-string* 4) #\B) → #\B 
 +*my-simple-string* → "​AAAABA" ​
 +([[CL:​Macros:​defparameter]] *my-filled-string* ​
 +  ([[CL:​Functions:​make-array]] 6 :​element-type '​[[CL:​Types:​character]]
 +                :​fill-pointer 5 
 +                :​initial-contents *my-simple-string*)) → "​AAAAB" ​
 +(char *my-filled-string* 4) → #\B 
 +(char *my-filled-string* 5) → #\A 
 +([[CL:​Macros:​setf]] (char *my-filled-string* 3) #\C) → #\C 
 +([[CL:​Macros:​setf]] (char *my-filled-string* 5) #\D) → #\D 
 +([[CL:​Macros:​setf]] ([[CL:​Functions:​fill-pointer]] *my-filled-string*) 6) → 6 
 +*my-filled-string* → "​AAACBD" ​
 +</​blockquote>​
 +
 +====Affected By====
 +None.
 +
 +====Exceptional Situations====
 +None.
 +
 +====See Also====
 +  * **[[CL:​Functions:​aref|Function AREF]]**
 +  * **[[CL:​Functions:​elt|Function ELT]]**
 +  * {\secref\ConstantModification}
 +
 +====Notes====
 +<​blockquote> ​
 +(char s j) ≡ ([[CL:​Functions:​aref]] ([[CL:​Special Operators:​the]] [[CL:​Types:​string]] s) j) 
 +</​blockquote>​
 +
 +\issue{CONSTANT-MODIFICATION:​DISALLOW}