On 08/21/2014 02:03 AM, Taylan Ulrich Bayirli/Kammer wrote:
> Per Bothner <[email protected]> writes:

>> Simple re-sizable vectors require an indirection that might otherwise
>> not be needed.  This overhead is much less than using linked lists.
>
> For accessing elements, yes.

Constructing a vector by appending to the end is also likely to be more 
efficient
than constructing a list: Less memory allocation/gc; better memory locality; 
about
the same memory needs.

>> 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 think the typical way of doing this is to cons up a reverse list,
> reverse! it, and use list->vector.  If the sequence is built at once
> then this should be fine.

Using a growable vector will be more efficient, and less programming.

-- 
        --Per Bothner
[email protected]   http://per.bothner.com/

_______________________________________________
Scheme-reports mailing list
[email protected]
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports

Reply via email to