If the string has a fill-pointer and maybe is also adjustable.
Adjustable = can change its size.
fill-pointer = the content size, the length, can be less than the string size.
VECTOR-PUSH
= add an element at the end and increment the fill-pointer.
VECTOR-PUSH-EXTEND
= as VECTOR-PUSH
, additionally resizes the array, if it is too small.
We can make an adjustable string from a normal string:
CL-USER 32 > (defun make-adjustable-string (s)
(make-array (length s)
:fill-pointer (length s)
:adjustable t
:initial-contents s
:element-type (array-element-type s)))
MAKE-ADJUSTABLE-STRING
VECTOR-PUSH-EXTEND
then can add characters to the end of the string. Here we add the character #\!
to the end of the string "Lisp"
. The result string then is "Lisp!"
:
CL-USER 33 > (let ((s (make-adjustable-string "Lisp")))
(vector-push-extend #\! s)
s)
"Lisp!"