Hello,

On Wed 21 Oct 2009 18:06, l...@gnu.org (Ludovic Courtès) writes:

> Andy Wingo <wi...@pobox.com> writes:
>
>> if your key takes time to
>> compute, you need to use the decorate-sort-undecorate idiom, otherwise
>> you compute the sort key O(n log n) times instead of O(n) times.
>
> If you insist:
>
>   (sort '((a . 1) (b . -2) (c . 3))
>         (memoized-lambda
>           (lambda (x y)
>             (< (cdr x) (cdr y)))))

This simply does not have the same characteristics. You have to memoize
the keys, not the comparisons. And a hash table does not have quite the
same characteristics.

> :-)

Sure, yes -- but it is somewhat distressing that we want different
Schemes.

> Also, it would be a departure from R5RS (and R6RS’ ‘list-sort’, FWIW).

It's a compatible extension.

Andy
-- 
http://wingolog.org/


Reply via email to