From: Richard F. <fa...@be...> - 2014-03-23 17:04:20
|
(defun $takewhile5(L p) (let ((c nil)(idx 0) (test nil)) (declare(fixnum idx)(optimize (speed 3)(safety 0))) (cons '(mlist) (nreverse (loop for x in (cdr L) finally (return c) do (incf idx) (setf test (mfuncall p x)) (if (and (not test) c)(return c)) (if test (push (list '(mlist) x idx) c))))))) I think one needs a larger example to test this one. It is maybe 10X or 20X faster than the previous one, depending on if you compile the lisp, and what lisp. So we are talking about 1200 X faster than the original. have fun. |