Re: [Scheme-reports] vector-insert Vassil Nikolov 21 Aug 2014 00:19 UTC

On Wed, 20 Aug 2014 14:31:42 -0700, Per Bothner <per@bothner.com> said:
> ...

> Many programs needs to "build" a
> sequence, typically appending at the end
> each element as it is produced.  Using an
> array that gets reallocated (doubled)
> when full is usually the most efficient
> representation.  Having a standard
> re-sizable (growable) vector type would
> simplify the programming.

> I added string-append! to Kawa.  It seems
> to be a good idea to also add
> vector-append!.

  As a corroborating side note (for what
  it's worth), the designers of Common Lisp
  found it fit to include VECTOR-PUSH and
  VECTOR-PUSH-EXTEND, which also covers
  strings.  Unlike NCONC for lists,
  however, Common Lisp does not offer a
  primitive to append a whole (sub)vector
  destructively.  This can be done with a
  call to REPLACE [*].

  Then Common Lisp has nothing like
  `vector-insert'.  For the non-destructive
  variant, one can compose CONCATENATE and
  SUBSEQ.  The destructive variant can be
  done with two calls to REPLACE [*].

  _________
  [*] possibly after calling ADJUST-ARRAY,
      and incrementing a fill pointer as
      needed

  ---Vassil.

--
Vassil Nikolov | Васил Николов | <vnikolov@pobox.com>

"Be careful how you fix what you don't understand."  (Brooks 2010, 185)

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