(loop for i below 10 finally (return i))return 9 or 10?
(loop for i upto 10 finally (return i))return 10 or 11?
- What does
(loop for i below 10 for j upto 10 finally (return (list i j)))return?
- What about
(loop for i below 10 and j upto 10 finally (return (list i j)))?
I stumbled upon the semantics of this last example in a recent bugfix and thought it was worth sharing. (Reminded me of the joke about what's hard in CS, too.)
FOR ... ANDnot only mimics
LET*) in terms of binding visibility, it also influences when the loop termination checks take place. That was new to me. I initially expected examples 3 and 4 to return the same values. What about you? Which ones, if any, did you get wrong? :-)
P.S.: LOOP for Black Belts is my favorite LOOP tutorial.