* David Kastrup (2008-06-07) writes: > Ralf Angeli <[EMAIL PROTECTED]> writes: > >> +(defun reftex-remove-if (predicate list) >> + "Nondestructively remove all items from LIST which satisfy PREDICATE." >> + (let (result) >> + (dolist (elt list) >> + (unless (funcall predicate elt) >> + (add-to-list 'result elt t))) >> + result)) >> + > > No, that's bad. Since it also uniquifies the list. add-to-list is an > O(n) operation, so this becomes O(n^2). > > Try rather > (let (result) > (dolist (elt list (nreverse result)) > (unless (funcall predicate elt) > (push elt result)))) > > This is O(n).
Thanks. Checked in. -- Ralf _______________________________________________ auctex-devel mailing list [email protected] http://lists.gnu.org/mailman/listinfo/auctex-devel
