Re: arrays vs. vectors



"H." <hbe123@xxxxxxxxx> writes:
>When a language exists that has an array type and a vector type (e.g.
>Java), how do the array and vector types in those languages correspond
>to the vector type in Scheme? Did Scheme pack everything into one type
>for which other languages need two?

A Java array is like a Scheme vector.

A Java vector is an attempt to have one's cake and eat it too. It's an
array that you add elements to, one by one, like CONS, and when you fill
it up, it automatically replaces itself with a bigger one. So lookup
is Theta(1), and insert is also Theta(1) but every so often there's a
Theta(N) delay as it copies itself.
.