Greetings,
second(), third(), etc. traverse the entire expression. But, they
don't need to. Here is a change that fixes that.
Example:
a:create_list(i,i,1,10^6)$
before change:
for i:1 thru 100 do second(a);
Evaluation took 0.4900 seconds (0.4860 elapsed)
after change:
for i:1 thru 100 do second(a);
Evaluation took 0.0000 seconds (0.0000 elapsed)
If it is decided that it should be applied, I can
make the patch. But someone else can do it, too.
Note especially that
(make-nth second 2)
was changed to
(make-nth second 1), etc.
--------
(macrolet ((make-nth (si i)
(let ((sim (intern (concatenate 'string "$" (symbol-name si)))))
`(defmfun ,sim (e)
(atomchk (setq e (format1 e)) ',sim nil)
(handler-case
(elt (margs e) ,i)
(error ()
(merror (intl:gettext "~:M: no such element
in ~M") ',sim e)))))))
; (if (< (length (margs e)) ,i)
; (merror (intl:gettext "~:M: no such element in ~M") ',sim e))
; (,si (margs e))))))
(make-nth second 1)
(make-nth third 2)
(make-nth fourth 3)
(make-nth fifth 4)
(make-nth sixth 5)
(make-nth seventh 6)
(make-nth eighth 7)
(make-nth ninth 8)
(make-nth tenth 9))