Re: vector-insert Taylan Ulrich Bayirli/Kammer (19 Aug 2014 16:17 UTC)
Re: [Scheme-reports] vector-insert John Cowan (19 Aug 2014 17:00 UTC)

Re: [Scheme-reports] vector-insert John Cowan 19 Aug 2014 16:56 UTC

Taylan Ulrich Bayirli/Kammer scripsit:

> > I am wondering if R7RS lacks a vector-insert.
>
> This comes down to resizable vectors in general, no?

I interpret the remarks about assignment as showing a desire to avoid
initializing a newly created vector only to clobber all of its locations
immediately thereafter.  This is still only O(n), but the constant factor
plus the page churn, if the vector is large, may be undesirable.

A possible implementation-specific approach would be to treat
`make-vector` without a fill argument as turning on a bit which says
"Don't allow `vector-ref` (vel sim.) on this vector, and don't follow
its elements for GC purposes."  Then the obvious vector-insert algorithm
would Just Work, provided there is some way of clearing the bit when
the programmer knows that every element has been set.

> How useful of a data structure are they?  If resizing/insertion is a
> common operation, there might be more suitable data structures?

See BuffersCowan for mutable resizable (within limits) vectors.

--
John Cowan          http://www.ccil.org/~cowan        cowan@ccil.org
What is the sound of Perl?  Is it not the sound of a [Ww]all that people
have stopped banging their head against?  --Larry

_______________________________________________
Scheme-reports mailing list
Scheme-reports@scheme-reports.org
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports