This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Scheme is too complicated






>> here's what I would call a functional version:
>>
>> (define hash->keys
>>   (lambda (mytab)
>>     (let ((bucket->keys (lambda (bucket) (map entry->key bucket)))
>>           (entry->key cadr))
>>       (apply append (map bucket->keys (vector->list (cdr mytab)))))))
>>
>> the functional guy is sleek and pretty, but those "vector->list" and
>> "append" bits are performance killers.
>
> Continuing the append
>example, in a scheme system with an exact generational garbage
>collector, append may not be a big problem, because the garbage
>collector can quickly reclaim the storage, without scanning the whole
>data space.

The other.. perhaps more important thing to remember is that.. despite the
temptation, lists and plain vectors are not the only data structures known
to man. One can conceive of a totally different data structure with it's
own version of apply, append and map that does not generate any garbage at
all
for the above algorithm, while still being functional.