common lisp - How to clear string with fill pointer? -
here's example saw @ hyperspec:
(setq fstr (make-array '(0) :element-type 'base-char :fill-pointer 0 :adjustable t)) (with-output-to-string (s fstr) (format s "here's output"))
so fstr
holds here's output
q: how simple clear/reset on fstr
in case want start on , put new in it, is, not concatenate more onto it? or have redo top expression fstr
being set up?
set fill pointer:
cl-user 3 > (setq fstr (make-array '(0) :element-type 'base-char :fill-pointer 0 :adjustable t)) "" cl-user 4 > (with-output-to-string (s fstr) (format s "here's output")) nil cl-user 5 > fstr "here's output" cl-user 6 > (setf (fill-pointer fstr) 0) 0 cl-user 7 > fstr "" cl-user 8 > (with-output-to-string (s fstr) (format s "here's more output")) nil cl-user 9 > fstr "here's more output"
you can call adjust-array
change array size.
cl-user 16 > (setf (fill-pointer fstr) 0) 0 cl-user 17 > (adjust-array fstr 0) ""
Comments
Post a Comment