I'm trying to do something like this
(loop for i from 1 to 10
do (let ((fi (funcall f i)))
when (> fi 0)
collect (list i fi)))
f is expensive to compute, so I want to only calculate it once.
This isn't working, so I introduce my fi local variable outside the loop scope:
(let ((fi nil))
(loop for i from 1 to 10
do (setf fi (funcall f i))
when (> fi 0)
collect (list i fi)))
Is there a way to do this (like the first way) that is completely contained within the loop macro?