Google Groups


Bernhard Pfahringer Dec 15, 1998 12:00 AM
Posted in group: comp.lang.lisp
In article <>, Erik Naggum  <> wrote:
>  I do (sort (cons <element> <sorted-list>) <test>) when adding one element
>  at a time to a priority list.  profiling shows that it is irrelevant to
>  the execution time of the program, although I'd bet that some form of
>  programmer instinct would be triggered by this particular example and
>  would try to rewrite it.
Yep, why not use:

 (merge 'list (list <element>) <sorted-list> <test>)

Not much of a rewrite, O(n), might not bite as early for larger priority lists.

Bernhard Pfahringer
Austrian Research Institute for
Artificial Intelligence