iterate is a Common Lisp library that aims to be a replacement for loop, being cleaner (subjectively) and portably extensible: https://common-lisp.net/project/iterate/
`repeat` is an iterate clause that tells iterate to perform N iterations of the loop:
(iterate (repeat 3) (print 'beep))
BEEP
BEEP
BEEP
As for this particular `for`, it's an iterate clause that handles numeric iteration (among other things). So:
(iterate (for x :from 0)
(for y :from 10 :downto 7)
(print (list x y)))
Would give you:
(0 10)
(1 9)
(2 8)
(3 7)
iterate will terminate the loop the first time any one of its clauses runs out of values/iterations. So in the post I had something like
(iterate (repeat N)
(for x :from start)
...)
You could write this as
(iterate (for x :from start :below (+ start N))
...)
But manually calculating the ending value seems ugly to me. I know I want the loop to happen N times so I just say `(repeat N)` and let the computer figure out when it's time to be done.
iterate is a Common Lisp library that aims to be a replacement for loop, being cleaner (subjectively) and portably extensible: https://common-lisp.net/project/iterate/
`repeat` is an iterate clause that tells iterate to perform N iterations of the loop:
As for this particular `for`, it's an iterate clause that handles numeric iteration (among other things). So: Would give you: iterate will terminate the loop the first time any one of its clauses runs out of values/iterations. So in the post I had something like You could write this as But manually calculating the ending value seems ugly to me. I know I want the loop to happen N times so I just say `(repeat N)` and let the computer figure out when it's time to be done.