I noticed that when using remove,remove-if etc. functions on an
adjustable array or an array with a fill-pointer, the result is an
array _without_ a fill-pointer and that is not adjustable.
Why is this?
And is there a way to remove elements from (the interior of a)
fill-pointer array and still have a fill-pointer array as the result
without defining a new fill-pointer-remove-if function or redefining
remove-if etc. ?
Thanks, Joachim.
Because the standard requires it:
Section 17.1:
"A sequence function is a function defined by this specification or
added as an extension by the implementation that operates on one or
more sequences. Whenever a sequence function must construct and return
a new vector, it always returns a simple vector. Similarly, any strings
constructed will be simple strings."
Paul
> joa...@arti.vub.ac.be wrote:
> > Why is this?
>
> Because the standard requires it (Section 17.1)
ok, this is rather uncounterable :-)
but what about my second question? Maybe I should rephrase it:
"What are fill-pointer arrays for if you can only implement a stack
with them and not e.g. remove elements?"
Joachim.
>> I noticed that when using remove,remove-if etc. functions on an
>> adjustable array or an array with a fill-pointer, the result is an
>> array _without_ a fill-pointer and that is not adjustable.
>>
>> Why is this?
>
>
> Because the standard requires it:
Atually, this isn't right. It's possible that arrays with fill
pointers or adjustable arrays are also simple, but they typically aren't
in Lisps implemented on stock hardware.
Paul
Because you ask for a new sequence with the `remove´ version.
Perhaps you should investigate the `delete´ versions?
--
Erik Naggum, Oslo, Norway
Act from reason, and failure makes you rethink and study harder.
Act from faith, and failure makes you blame someone and push harder.
> "What are fill-pointer arrays for if you can only implement a stack
> with them and not e.g. remove elements?"
Well, the classic answer would be some kind of buffer object. Say I'm
reading chunks of data into a buffer, and I don't know how big they
are, but I know there's some maximum size (or maybe, if the size is
bigger than I've allowed for I'm willing to use ADJUST-ARRAY to
allocate a bigger buffer). I want to reuse the buffer, but I don't
want to have to keep passing around the information that only the
first n elements of this thing actually have useful data. So I use a
fill pointer to tell me that.
However, going back to your original question, I think you may be
confused about what REMOVE &co do - they are nondestructive functions,
so they aren't allowed to alter the arrays that are their arguments.
DELETE &co are allowed to be destructive, but don't have to be so.
--tim