Here is just a simplified code snipped I have not managed to work. I do not understand what is wrong.
(defun enumerate-indicies (func)
(let ((index 0))
(while (< index 5)
(funcall func index)
(setq index (1+ index)))))
(defun enumerate-multiplied-indicies (func)
(enumerate-indicies #'(lambda (index)
(funcall func (* 10 index)))))
The following testing code returns 10
as expected:
(defun test/enumerate-indicies ()
(let ((sum 0))
(enumerate-indicies #'(lambda (index)
(setq sum (+ sum index))))
sum))
(test/enumerate-indicies)
But the below causes error Lisp nesting exceeds max-lisp-eval-depth
in my Emacs:
(defun test/enumerate-multiplied-indicies ()
(let ((sum 0))
(enumerate-multiplied-indicies #'(lambda (index)
(setq sum (+ sum index))))
sum))
(test/enumerate-multiplied-indicies)
Could you please give my a clue? That is not supposed be a recursive call here but seems that it is. Thanks.
How about using
lexical-let
to penetrate thelambda
? Is the correct answer 100?