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 fstrin 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

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -