From: Cory Spencer
Subject: Resizing a vector...
Date: 
Message-ID: <a0040f$3nb$1@nntp.itservices.ubc.ca>
How would I go about resizing a vector that I've received as the return
result from a function?  (The vectors that I am getting back are of a
variable length, and I'd like to ensure that they're all of at least a
certain size.)

Cory

From: Kent M Pitman
Subject: Re: Resizing a vector...
Date: 
Message-ID: <sfw8zbw1gqe.fsf@shell01.TheWorld.com>
Cory Spencer <········@interchange.ubc.ca> writes:

> How would I go about resizing a vector that I've received as the return
> result from a function?  (The vectors that I am getting back are of a
> variable length, and I'd like to ensure that they're all of at least a
> certain size.)

Variable length vectors have two ways of being extended. They have a 
store of a known size (the dimension).  The FILL-POINTER is a count
kept of valid elements.  You can SETF the FILL-POINTER to change the
number of valid elements up to the allocated dimension.

If the array was allocated with the :ADJUSTABLE T option to MAKE-ARRAY,
you can also use ADJUST-ARRAY to change its size upward, or you can use
VECTOR-PUSH-EXTEND to add individual elements (bumping the fill pointer
each time, and extending the allocated size automatically if you exceed
it).  Note that the extending operation if you overrun the valid size still
usually involves copying your existing hidden store to a bigger hidden store
and the updating the array header to point to the new hidden store, so try
to guess accurately in the first place about what size you'll need.  
Extending is generally not cost-free.
From: Barry Margolin
Subject: Re: Resizing a vector...
Date: 
Message-ID: <q4OU7.54$UU.169682@burlma1-snr2>
In article <············@nntp.itservices.ubc.ca>,
Cory Spencer  <········@interchange.ubc.ca> wrote:
>How would I go about resizing a vector that I've received as the return
>result from a function?  (The vectors that I am getting back are of a
>variable length, and I'd like to ensure that they're all of at least a
>certain size.)

Use ADJUST-ARRAY.  Note that if the vectors were not created with the
:ADJUSTABLE T option to MAKE-ARRAY, ADJUST-ARRAY might return a new vector
rather than modifying the existing vector, so you'll need to do something
like:

(setq the-vector (adjust-array the-vector new-size))

-- 
Barry Margolin, ······@genuity.net
Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.